title: Custom SOAP Headers
body: <p>I am trying to convert a Java Web Service client to C#.  I have add a custom SoapHeader class to generate the necessary headers for authentication, but they are not being correctly formatted.  I am very new to C# Web Services, so any help is very appreciated.</p>
  
  <p>Here is the format in which i need the headers:</p>
  
  <pre><code>  &lt;soapenv:Header&gt;  
       &lt;USER soapenv:mustUnderstand="0" xsi:type="xsd:string"&gt;xxx&lt;/USER&gt;  
       &lt;PASSWORD soapenv:mustUnderstand="0" xsi:type="xsd:string"&gt;yyy&lt;/PASSWORD&gt; 
    &lt;/soapenv:Header&gt; 
  </code></pre>
  
  <p>Here is what is being generated by the C# client:</p>
  
  <pre><code>  &lt;soap:Header&gt;
       &lt;wsa:Action&gt;&lt;/wsa:Action&gt;
       &lt;wsa:MessageID&gt;urn:uuid:ecb804bb-1104-4bfc-a8f8-c5f757d428fb&lt;/wsa:MessageID&gt;
       &lt;wsa:ReplyTo&gt;
          &lt;wsa:Address&gt;http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous&lt;/wsa:Address&gt;
       &lt;/wsa:ReplyTo&gt;
       &lt;wsa:To&gt;http://localhost:8081/emsapi/services/PSXAPI/r09_00_00&lt;/wsa:To&gt;
       &lt;wsse:Security&gt;
          &lt;wsu:Timestamp wsu:Id="Timestamp-4e8c838e-230c-4fb3-99b0-74f46f3652fa"&gt;
             &lt;wsu:Created&gt;2013-07-19T17:26:55Z&lt;/wsu:Created&gt;
             &lt;wsu:Expires&gt;2013-07-19T17:31:55Z&lt;/wsu:Expires&gt;
          &lt;/wsu:Timestamp&gt;
       &lt;/wsse:Security&gt;
    &lt;/soap:Header&gt;
  </code></pre>
  
  <p>What do i need to put into my SoapHeader class to format them correctly?  For your reference, here is the header class:</p>
  
  <pre><code>public class AuthHeaders : SoapHeader {
      [System.Xml.Serialization.SoapElement("USER")]
      [System.Xml.Serialization.SoapAttribute("USER")]
      public string USER;
      [System.Xml.Serialization.SoapElement("PASSWORD")]
      public string PASSWORD;
  }
  </code></pre>