azec.me
azec.me

Reputation: 5078

How to make PHP Soap 1.1 call with non-default Content-Type

I need to make call to SOAP 1.1 web service in PHP. However, one of requirements in order to work is that I must send Content-Type=application/soap+xml. Now, I know that these are differences:

I need to use SoapClient with WSDL to do this. However, I couldn't find how to set Content-Type after I set version to SoapClient to 1.1

Could someone provide example or code snippet?

Thank you!

Upvotes: 5

Views: 9785

Answers (2)

David
David

Reputation: 21

There are a number of headers that are ignored when you try to set them in a stream_context, and will never be used.

Check the underlying C source file soap/php_http.c and search for "skip some predefined headers" for a list.

This is the reason some people report problems trying to set Host, Authorization, Content-Type and other headers in certain situations.

Upvotes: 2

Daniel Basedow
Daniel Basedow

Reputation: 13396

You can supply a stream context in the SoapClient options.

$ctx_opts = array(
    'http' => array(
        'header' => 'Content-Type: application/soap+xml'
    )
);

$ctx = stream_context_create($ctx_opts);
$soapClient = new SoapClient('your.wsdl', array('stream_context' => $ctx));

Upvotes: 1

Related Questions