Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • SOAP 1.2 -> Content-Type: application/soap+xml
  • SOAP 1.1 -> Content-Type: text/xml

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!

like image 909
azec-pdx Avatar asked Oct 20 '22 22:10

azec-pdx


1 Answers

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.

like image 82
David Avatar answered Oct 27 '22 10:10

David