简体   繁体   English

如何设置这个PHP肥皂头?

[英]How to set this php soap header?

How do i set this php Soap Header ?? 我如何设置此php Soap Header? For the life of me I can't figure it out. 对于我的一生,我无法弄清楚。

   <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>

Thanks guys ! 多谢你们 !

See this comment: 看到这个评论:

http://www.php.net/manual/en/soapclient.setsoapheaders.php#93460 http://www.php.net/manual/zh/soapclient.setsoapheaders.php#93460

So it would be like: 就像这样:

$headerbody = array('UsernameKey'=>array('Username'=>$UserID,
                                         'Password'=>$Pwd)); 
$header = new SoapHeader($ns, 'RequestorCredentials', $headerbody);       

//set the Headers of Soap Client.
$soap_client->__setSoapHeaders($header); 

I feel that the answer to this question is a bit misleading; 我觉得这个问题的答案有点误导; WSSE headers, as in the OP's example snippet, are slightly more complicated... 像OP的示例片段中一样,WSSE标头稍微复杂一些……

A verbose example of the correct implementation using PHP's SoapClient can be found here: http://www.php.net/manual/en/soapclient.soapclient.php#97273 可以在此处找到使用PHP的SoapClient正确实现的详细示例: http : //www.php.net/manual/zh/soapclient.soapclient.php#97273

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM