Note that there are some explanatory texts on larger screens.

plurals
  1. POWeb service request authentication
    primarykey
    data
    text
    <p>We're being really stuck here so I decided to ask your help.</p> <p>Yesterday I've been asked to help to consume a web service, got the URL to the WSDL, and the user credentials to use. I've never really had anything to do with web services, but having a general idea about them and seeing a few examples I thought it can't be that bad. Obviously I was wrong as I'm stuck now.</p> <p>Everything seems to be fine, the proxy class (or client) has been generated, building up requests and sending them are fine too, apart from the authentication part. Which we can't seem to figure out how to do.</p> <p>Using the:</p> <pre><code>client.ChannelFactory.Credentials.UserName.UserName = "myusername"; client.ChannelFactory.Credentials.UserName.Password = "mypassword"; </code></pre> <p>doesn't seem to work. (When I check the BindingElementCollection returbed by the client.Endpoint.Binding.CreateBindingElements() there's no SecurityBindingElement)</p> <p>I've tried so many other ways of doing it, but I think I'm missing something basic and the lack of documentaion is not really helping either.</p> <p>So the question is: How do I send the username and password when making a call to a web service, using WCF?</p> <p><strong>Edit:</strong> Just to clarify, the request should contain something similar to this:</p> <pre><code> &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1"&gt; &lt;wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-25763165"&gt; &lt;wsse:Username&gt;username&lt;/wsse:Username&gt; &lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"&gt;1DiaGTkOLk/CZhDaEpbkAaKRfGw=&lt;/wsse:Password&gt; &lt;wsse:Nonce&gt;6ApOnLn5Aq9KSH46pzzcZA==&lt;/wsse:Nonce&gt; &lt;wsu:Created&gt;2009-05-13T18:59:23.309Z&lt;/wsu:Created&gt; &lt;/wsse:UsernameToken&gt; &lt;/wsse:Security&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload