03 Oct 2008

While testing a WCF service running in IIS with a simple Axis2 client, we encountered a content type error:

org.apache.axis2.AxisFault: Transport error: 415 Error: Cannot process the message because the content type 'application/soap+xml; charset=UTF-8; action="[...]"' was not the expected type 'text/xml; charset=utf-8'.

Using MSSoapT, we could see that the content type of the request was application/soap+xml.

So, looks like Axis2 client is using SOAP 1.2 messages and WCF service replies using SOAP 1.1 messages. According to this post by Aaron Skonnard, BasicHttpBinding uses SOAP 1.1 messages.

It is not possible to specify the message encoding in the binding section of the configuration file. Hence, the only way to make the server match the client is by using a CustomBinding that will be like BasicHttpBinding but use SOAP 1.2 instead of SOAP 1.1 as message encoding.

This can be easily achieved in the configuration file by adding a customBinding in bindings section:

  <binding name="customHttpBinding">
    <textMessageEncoding messageVersion="Soap12" />

Next, change the endpoint binding to use customBinding and use the bindingConfiguration attribute to point to the newly created binding configuration (in the example, customHttpBinding).

Running the client again worked this time, and MSSoapT was showing application/soap+xml content type in request and response's HTTP headers.

blog comments powered by Disqus