如何设置这个php Soap Header?对于我的生活,我无法理解。
<soapenv:Header>
<wsse:HeaderOne soapenv:mustUnderstand="1">
<wsse:UsernameKey wsu:Id="tun-12345">
<wsse:Username>myusername</wsse:Username>
<wsse:Password>mypassword</wsse:Password>
</wsse:UsernameKey>
</wsse:HeaderOne>
</soapenv:Header>
谢谢你们!
答案 0 :(得分:8)
请参阅此评论:
http://www.php.net/manual/en/soapclient.setsoapheaders.php#93460
所以它会像:
$headerbody = array('UsernameKey'=>array('Username'=>$UserID,
'Password'=>$Pwd));
$header = new SOAPHeader($ns, 'RequestorCredentials', $headerbody);
//set the Headers of Soap Client.
$soap_client->__setSoapHeaders($header);
答案 1 :(得分:2)
我觉得这个问题的答案有点误导;与OP的示例代码段中一样,WSSE标头稍微复杂一些......
可以在此处找到使用PHP的SoapClient进行正确实现的详细示例: http://www.php.net/manual/en/soapclient.soapclient.php#97273