The SoapClient constructor will not read all of the stream_context options when generating the request headers. However, you can place arbitrary headers in a single string in a header
option inside http
:
$soapclient = new SoapClient($wsdl, [
'stream_context' => stream_context_create([
'user_agent' => 'PHP/SOAP',
'http'=> [
'header' => "Accept: application/xml\r\n
X-WHATEVER: something"
]
])
]);
For setting more than one, separate them by \r\n
.
(As mentioned by Ian Phillips, the "user_agent" can be placed either at the root of the stream_context, or inside the "http" part.)