我正在寻找解决方案来更改必须在 SOAP 请求中发送的标头,扩展 __doRequest 解决了它。
class MSSoapClient extends SoapClient {
function __doRequest($request, $location, $action, $version) {
$header = '<SOAP-ENV:Header>
<ns1:AuthenticationHeader>
<ns1:Username>XXXX</ns1:Username>
<ns1:Password>XXXX</ns1:Password>
<ns1:Function>XXX</ns1:Function>
<ns1:TimeOutMilliSec>4000</ns1:TimeOutMilliSec>
</ns1:AuthenticationHeader>
</SOAP-ENV:Header><SOAP-ENV:Body>';
$request = str_replace('<SOAP-ENV:Body>', $header, $request);
return parent::__doRequest($request, $location, $action, $version);
}
$client = new MSSoapClient($wsdl, array('trace' => 1, "exceptions" => 0, 'use' => SOAP_LITERAL));