I am writing a WCF service, running on IIS, and I have a customer whose client can only talk SOAP 1.1.
Among other things, they need the content type to be "application/soap+xml; charset=utf-8". My WCF service is sending "text/xml; charset=utf-8".
The customer who's trying to write the client forwarded me an error message:
HTTP 415: Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8
Browsing around the net, I found a number of blog pages like this: WCF Error - The request failed with HTTP status 415.
Which made me think that switching from wsHttpBinding to basicHttpBinding would fix this. So I changed the binding in the web.config, and modified my own test client to explicitly create an endpoint with a BasicHttpBinding. And that all worked fine, in my own tests (both running the service in Visual Studio's Dev Server, and running it in IIS7 on my own machine, and running it in IIS6 on one of our test servers.)
But before I gave the customer a head's up, and asked them to see if my changes would work for them, I fired up Fiddler to eavesdrop on the actual traffic.
And according to Fiddler, I'm still sending "text/xml; charset=utf-8".
So, how do I fix that?
<system.serviceModel>
<services>
<service behaviorConfiguration="myBehavior" name="myName">
<endpoint
address=""
binding="basicHttpBinding"
behaviorConfiguration="flatWsdlFileEndpointBehavior"
bindingNamespace="http://myNamespace"
contract="myContract">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="flatWsdlFileEndpointBehavior">
<wsdlExtensions location="myUrl" singleFile="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<extensions>
<behaviorExtensions>
<add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
So do they need SOAP 1.1 or application/soap+xml; charset=utf-8
? Because SOAP 1.1 specification says that the request must have text/xml
as the media type. application/soap+xml
is media type for SOAP 1.2. Forcing WCF to use SOAP 1.1 with application/soap+xml
(= invalid SOAP) would require bigger changes than changing the binding. You will need some custom message encoder or perhaps transport channel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With