如何设置这个 php soap 标头?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7145143/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:08:43  来源:igfitidea点击:

How to set this php soap header?

phpsoapheader

提问by koos

How do i set this php Soap Header ?? For the life of me I can't figure it out.

我如何设置这个 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>

Thanks guys !

谢谢你们 !

回答by rickyduck

See this comment:

看到这个评论:

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

http://www.php.net/manual/en/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);