Monday, February 6, 2012

Transport error: 415 Error: Cannot process the message because the content type ...


Today I ran into the following error while using an Axis2 Java Client to consume a WCF Soap Service.

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

This problem is caused because the WCF SOAP service is using SOAP 1.1 while the Axis2 Client defaults to SOAP 1.2

The fix is to set the Soap Version URI in the Axis2 ServiceClient options as follows:


stub._getServiceClient()
       .getOptions()
       .setSoapVersionURI(
                   SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

3 comments: