title: WCF SOAP 1.2 service expecting SOAP 1.1 content type
body: <p>I'm building a WCF web service that requires interop with non-WCF clients (in fact, there will be no WCF clients).</p>
  
  <p>I've already written a WSDL using SOAP 1.2 (<a href="http://schemas.xmlsoap.org/wsdl/soap12/soap12WSDL.htm" rel="noreferrer">as per this example</a>). I've validated the WSDL and have used this file (not the WSDL generated by WCF, which is superficially different) to create a <a href="http://www.soapui.org/" rel="noreferrer">soapUI</a> test project.</p>
  
  <p>I have a requirement that the web service will support SOAP 1.2, so I can't just fall back to SOAP 1.1 (which worked just fine in an early prototype).</p>
  
  <p>I've used <a href="http://wscfblue.codeplex.com/" rel="noreferrer">WSCF.blue</a> to generate my WCF service, interface, and data contract classes. Everything compiles nicely and the endpoint is exposed if I hit the WCF service in my browser. All seems well with the world.</p>
  
  <p>When I try to call a method from soapUi I get the following response from the server (as visible from soapUI):</p>
  
  <pre><code>HTTP/1.1 415 Cannot process the message because the content type 
  'application/soap+xml;charset=UTF-8;action="http://tempuri.org/FetchMyThing"' 
  was not the expected type 'text/xml; charset=utf-8'.
  Server: Microsoft-IIS/7.5
  X-Powered-By: ASP.NET
  Date: Mon, 30 Apr 2012 08:15:29 GMT
  Content-Length: 0
  </code></pre>
  
  <p>(Actual method names and namespaces have been manually changed for the purposes of this question. Any typos in namespace are not errors in my code - just an oversight in typing up this question)</p>
  
  <p>I know that SOAP 1.1 specifies that the content type must be <strong>text/xml</strong>. SOAP 1.2 requires <strong>application/soap+xml</strong>. </p>
  
  <p>My raw request (as per soapUI):</p>
  
  <pre><code>POST http://localhost/MyWs.svc HTTP/1.1
  Accept-Encoding: gzip,deflate
  Content-Type: application/soap+xml;charset=UTF-8;action="http://tempuri.org/FetchMyThing"
  
  &lt;soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
                 xmlns:ns="http://tempuri.org"&gt;
     &lt;soap:Header/&gt;
     &lt;soap:Body&gt;
        &lt;ns:fetchMyThingRequest attribute1="1" attribute2="10"&gt;
        &lt;/ns:fetchMyThingRequest&gt;
     &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>From this response, it tells me that my request is properly formed - it's a SOAP 1.2 request with the correct content type. My WCF service, however, does not expect this content type, which I assume means I have not configured it correctly and it still thinks it's a SOAP 1.1 web service.</p>
  
  <p>Minimal Web.config, as per <a href="http://blog.allanglen.com/2010/05/implementing-a-minimal-soap-1-2-binding-in-wcf" rel="noreferrer">this blog post</a>:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
    &lt;services&gt;
      &lt;service name="MyNamespace.MyPort"&gt;
        &lt;endpoint address="" binding="customBinding" bindingConfiguration="httpSoap12" contract="IWsPort12" /&gt;
      &lt;/service&gt;
    &lt;/services&gt;
  
    &lt;bindings&gt;
      &lt;customBinding&gt;
        &lt;binding name="httpSoap12"&gt;
          &lt;textMessageEncoding messageVersion="Soap12" /&gt;
          &lt;httpTransport /&gt;
        &lt;/binding&gt;
      &lt;/customBinding&gt;
    &lt;/bindings&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>A snippet of the service contract:</p>
  
  <pre><code>[ServiceContract(Namespace = "http://tempuri.org")]
  public interface IWsPort
  {
    [OperationContract(Action = "http://tempuri.org/FetchMyThing")]
    [FaultContract(typeof(WsFault), Action = "http://tempuri.org/FetchMyThing", Name = "fetchMyThingFault")]
    [XmlSerializerFormat(SupportFaults = true)]
    FetchMyThingResponse FetchMyThing(FetchMyThingRequest request);
  }
  </code></pre>
  
  <p>I enabled service tracing for my WCF service and see the following exception that seems to confirm my hypothesis:</p>
  
  <pre><code>Activity: Listen at 'http://mycomputer/MyWs.svc
  &lt;Exception&gt;
    &lt;ExceptionType&gt;System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/ExceptionType&gt;
    &lt;Message&gt;Content Type application/soap+xml;charset=UTF-8;action="http://tempuri.org/FetchMyThing" was sent to a service expecting text/xml; charset=utf-8.  The client and service bindings may be mismatched.   
    &lt;/Message&gt;
  (erroneous detail snipped)
  &lt;/Exception&gt;
  </code></pre>
  
  <p>So, my contract and service bindings are probably mismatched, if this message is to believed, but from what I understand of WCF my configuration (or at least the intent behind it) is correct.</p>
  
  <p>Does anyone have any ideas as to what's wrong with my configuration?</p>