skip to content

Sign In

Register  |  Forgot Password

PHP programming tips: Soap content type error

I've been struggling putting together a soap client that accesses the property24 soap feed, and with the example code I got from their documentation, I received the following HTTP error:

Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'multipart/related; type="application/xop+xml"'.

After googling and searching on various other sources, I still couldn't find a solution to the problem.  I decided to just ensure my soap client instance were initialised in the proper manner, and the problem magically dissappeared when I added 'soap_version' => SOAP_1_2 to the soap options, so that my code became:

$soapClient = new SoapClient($soapURL, array("trace" => 1,'soap_version' => SOAP_1_2,'style' => SOAP_DOCUMENT,'encoding' => SOAP_LITERAL,'cache_wsdl' => WSDL_CACHE_NONE));

The solution is so simple, yet I couldn't find a single website documenting the issue, so I decided to post it here in case anybody else ever needs it.