title: Adding custom SoapClient headers
body: <p>I'm a complete C# newbie and have been trying to crack this for a couple of hours now with no success...</p>
  
  <p>I need to build a SoapClient to use on C#... I've been trying to port an existing php client to c#.</p>
  
  <p>basically: I need to make a request with a Soap header which contains user and password, this is an example of xml I should be sending.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://webservices.paymentmanager.mycheck.com"&gt;
      &lt;soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
          &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
              &lt;wsse:UsernameToken&gt;
                  &lt;wsse:Username&gt;test&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;pass&lt;/wsse:Password&gt;
              &lt;/wsse:UsernameToken&gt;
          &lt;/wsse:Security&gt;
      &lt;/soapenv:Header&gt;
      &lt;SOAP-ENV:Body&gt;
          &lt;ns1:testws&gt;
              &lt;ns1:x&gt;1&lt;/ns1:x&gt;
          &lt;/ns1:testws&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>I used Visual Studio 'Add Service Reference...' When I do through </p>
  
  <p>The service is working well, as using php it works brilliantly.</p>
  
  <p>the C# I have concieved:</p>
  
  <pre><code>namespace ConsoleApplication1
  {
      class Program
      {
          const String VENDOR_ID = "8723";
          const String VENDOR_PASS = "test";
          const String VENDOR_USER = "pass";
          static void Main(string[] args)
          {
              try
              {
                  PaymentManager.PaymentManagerPortTypeClient test = new PaymentManager.PaymentManagerPortTypeClient();
                  int num = test.testws(5);
                  Console.WriteLine(num);
              }
              catch( Exception e)
              {
                  Console.WriteLine(e.ToString());
              }
          }
      }
  
  }
  </code></pre>
  
  <p>obviously, I didn't know how to implement the Soap headers, so it throws a 'Missing SOAP Headers' Exception (which is recieved from the WebService).</p>