title: Adding SOAP:HEADER username and password with WSE 3.0
body: <p>I have successfully created a WS client that works correctly when NOT using authentication.</p>
  
  <p>However, the server (WebSphere) now requires adding a ws-security username token, and I'm having a hard time doing this.  The resulting SOAP message is supposed to look something like this:</p>
  
  <pre><code>&lt;soapenv:Envelope 
    xmlns:ns="http://foo.bar/1.0"
    xmlns:ns1="http://www.witsml.org/schemas/140"   
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  
    &lt;soapenv:Header&gt;
  
      &lt;wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
        &lt;wsse:UsernameToken wsu:Id="UsernameToken-2" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
          &lt;wsse:Username&gt;foo&lt;/wsse:Username&gt;
          &lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;bar&lt;/wsse:Password&gt;    
          &lt;wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"&gt;foooooobar==&lt;/wsse:Nonce&gt;
          &lt;wsu:Created&gt;2010-01-25T13:09:24.860Z&lt;/wsu:Created&gt;
        &lt;/wsse:UsernameToken&gt;
      &lt;/wsse:Security&gt;
  
    &lt;/soapenv:Header&gt;
  
    &lt;soapenv:Body&gt;
      &lt;ns:fooBar&gt;...&lt;/ns:fooBar&gt;
    &lt;/soapenv:Body&gt;
  </code></pre>
  
  <p>I've downloaded and installed Microsoft's WSE 3.0 SDK and added a reference to the DLL in my Visual Studio 2005 project.</p>
  
  <p>I now have access to the Microsoft.Web.Services3.* namespaces, but I'm currently stumped on how to proceed.</p>
  
  <p>The client code has been generated automatically by a web reference, so I only do a minor amount of work to send the message to the server <em>unauthenticated</em>:</p>
  
  <pre><code>WS.FooResultHttpService ws = new WS.FooResultHttpService();
  ws.Url = "http://foo.bar.baz";
  ws.SendSomething(message);
  </code></pre>
  
  <p>I've just begun to investigate using <code>Microsoft.Web.Services3.Security.Tokens.UsernameTokenManager</code>, but so far I haven't been able to get anything up and running.</p>
  
  <p>Any hints would be greatly appreciated, as I can't seem to find any good recipes on the net.</p>
  
  <p>Thanks!</p>