title: adding http headers in call to SoapHttpClient service
body: <p>I have to consume a service provided by one of our partners.  I was given little direction, but was told the security was to be PasswordDigest.  I looked it up and immediatly saw lots of references to WSE, so off I went.  It was very easy to implement and in no time I had a standard WSE user token using PasswordDigest sitting in the SOAP headers of my messages.</p>
  
  <p>When we started testing today I was immediatly told (by the error message) that things weren't right.  Turns out, out partner doesn't look in the SOAP header, but rather wants the security info in the http header.</p>
  
  <p>I have seen lots of articles on how to add custom http headers to a proxy class, but my proxy inherits from SoapHttpClientProtocol which doesn't have a headers collection to add to.  I was looking at making a raw httpWebRequest, but I have a specific method to access that has some complex parameters to deal with (and besides it feels like going backwords).</p>
  
  <p>What is the best way to add custom http headers to a service proxy class that doesn't have a GetWebRequest method?</p>
  
  <p><strong>For reference:</strong></p>
  
  <p><strong>Proxy class decleration:</strong></p>
  
  <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Web.Services.WebServiceBindingAttribute(Name="MtomServiceSoap11", namespace="http://ws.xxxxxxx.com/")]
  public partial class MtomServiceService : System.Web.Services.Protocols.SoapHttpClientProtocol {
  </code></pre>
  
  <p><strong>Target method I need to call:</strong></p>
  
  <pre><code>[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
  [return: System.Xml.Serialization.XmlElementAttribute("uploadDocumentResponse", Namespace="http://ws.edsmtom.citizensfla.com/")]
  public uploadDocumentResponse uploadDocument([System.Xml.Serialization.XmlElementAttribute(Namespace="http://ws.xxxxxxx.com/")] uploadDocumentRequest uploadDocumentRequest) {
      object[] results = this.Invoke("uploadDocument", new object[] {
          uploadDocumentRequest});
          return ((uploadDocumentResponse)(results[0]));
      }
  }
  </code></pre>
  
  <p>The actual call to the Service is simple.  The objects being pass in are not:</p>
  
  <pre><code>request.criteria = docCriteria;
  request.document = document;
  var result = service.uploadDocument(request);
  </code></pre>
  
  <p>Thanks.</p>