title: C# SOAP Service - Remove method node and have header in soapheader node
body: <p>I'm tasked with creating a web service that conforms to a particular wsdl and I haven't used SOAP or asmx before.</p>
  
  <p>When I create a request in SoapUI I get the following structure, which is the same as the client will be using to send requests. (using placeholder names)</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:par="http://www.foo.com/schemas/method"&gt;
     &lt;soapenv:Header&gt;
        &lt;par:SOAPHeaderRequest&gt;
           &lt;par:ApplicationID&gt;ID&lt;/par:ApplicationID&gt;
        &lt;/par:SOAPHeaderRequest&gt;
     &lt;/soapenv:Header&gt;
     &lt;soapenv:Body&gt;
        &lt;par:Body&gt;
        &lt;/par:Body&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>However, when I'm trying to create the service I have this structure:</p>
  
  <pre><code>&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soap:Body&gt;
      &lt;Method xmlns="http://www.foo.com/schemas/method"&gt;
        &lt;request&gt;
          &lt;SOAPHeaderRequest&gt;
            &lt;ApplicationID&gt;string&lt;/ApplicationID&gt;
          &lt;/SOAPHeaderRequest&gt;
          &lt;body&gt;
            &lt;Property&gt;string&lt;/Property&gt;
          &lt;/body&gt;
        &lt;/request&gt;
      &lt;/Method&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>I'd like to know how to remove the Method node wrapper, and how to move the SOAPHeaderREquest into a soap:Header.</p>
  
  <p>Here's my sample code:</p>
  
  <p>interface and objects</p>
  
  <pre><code> [ServiceContract(Namespace = "http://www.foo.com/schemas/method")]
   public interface IServiceContract
   {
       [XmlSerializerFormat]
       [OperationContract]
       ResponseObject Method(RequestObject request);
   }
  
   [System.Serializable()]
   [System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://www.foo.com/schemas/method")]
   [MessageContract(IsWrapped = false)]
   public class RequestObject
   {
       [System.ServiceModel.MessageHeader(Namespace = "http://www.foo.com/schemas/method")]
       public SOAPHeaderRequest SOAPHeaderRequest;
  
       [System.ServiceModel.MessageBodyMember(Namespace = "http://www.foo.com/schemas/method", Order = 0)]
       public Body body;
  
       public RequestObject()
       {
       }
  
       public RequestObject(SOAPHeaderRequest SOAPHeaderRequest, Body body)
       {
           this.body = body;
       }
   }
  
   [System.Serializable()]
   [System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://www.foo.com/schemas/method")]
   [MessageContract(IsWrapped = false)]
   public class ResponseObject
   {
       [System.ServiceModel.MessageHeader(Namespace = "http://www.foo.com/schemas/method")]
       public SOAPHeaderResponse SOAPHeaderResponse;
  
       [System.ServiceModel.MessageBodyMember(Namespace = "http://www.foo.com/schemas/method", Order = 0)]
       public Body body;
   }
  
  
   [System.Serializable()]
   public class Body
   {
       public string Property { get; set; }
   }
  </code></pre>
  
  <p>asmx</p>
  
  <pre><code>[WebService(Namespace = "http://www.foo.com/schemas/method")]
  [WebServiceBinding(ConformsTo = WsiProfiles.None)]
  public class M5NapaPartUpdateService : WebService, IServiceContract
  {
      [WebMethod]
      [SoapMethod(SoapAction = "method")]
      public ResponseObject Method(RequestObject request)
      {
          return new ResponseObject();
      }
  }
  </code></pre>
  
  <p>Let me know if there's anything else you'd need.</p>
  
  <p>Thanks!</p>