Adding HTTP Headers to PHP SOAP requests

I was confronted lately with the requirement to send a SOAP request with additional HTTP headers attached to it (Not SOAP headers, which are passed as part of the SOAP XML envelope). After some research i only found some quite hackisch solutions.

But then Dmitry pointed my to a solution using stream context (which was not too obvious to me):

$x = new SoapClient($wsdl, array("stream_context" =>
        "header"=> "Accept-language: en\r\n".
                   "Cookie: foo=bar\r\n"


Auf Facebook teilen

« Plat_Forms contest 2011 - Plat_Forms Contest 2011: it was great fun »