Two notes about the steam_context option:
1- In the example of the documentation, it says:
<?php
$client = new SoapClient("some.wsdl", ['context' => $context]);
?>
This is wrong. As it is stated in the parameters list, it must be "stream_context" and NOT "context".
2- The HTTP Context manual here: https://www.php.net/manual/en/context.http.php
It says header can either be of type array or string. This is also wrong. It may not necessarily be optional because it might depend on your PHP compile time configuration.
If your instance is compiled --with-curlwrappers option, you should use array type for header in the HTTP context and if not; you should use a string separated by new line (\n) for the header. I am not sure if SoapClient respects curl_wrappers option because although it is enabled in my instance and although I am using arrays for the headers to create HTTP context for non-Soap operations; SoapClient required me to use a string. It otherwise just dropped the stream_context altogether.
So with SoapClient, you better use a string for the HTTP header like:
<?php
$context = stream_context_create(array(
'http' => array(
'user_agent' => 'My App',
'header' =>
"Custom-Header: Value\n" .
"Another Header: Surprise"
)
));
$client = new SoapClient('some.wsdl', ['stream_context' => $context]);
?>