Adding HTTP Headers to PHP SOAP requests
von Gaylord, am 8 Dezember 2010 - 0 Kommentare
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" => stream_context_create(array("http"=>array( "header"=> "Accept-language: en\r\n". "Cookie: foo=bar\r\n" ))))); $x->remoteFunction();