两个简单的 PHP SOAP setHeaders 问题
这是我用来生成请求标头的代码:
$headers = array(
new SOAPHEADER($this->_ns,'username',$this->_username,false, $this->_actor),
new SOAPHEADER($this->_ns,'password',$this->_password,false, $this->_actor));
$this->_client->__setSOAPHeaders($headers);
这会生成:
<SOAP-ENV:Header>
<ns2:username SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next">test</ns2:username>
<ns2:password SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next">test</ns2:password>
</SOAP-ENV:Header>
一切都很好。
这是我的两个问题:
API 文档要求用户名为 ns1:username,密码为 ns2:password。我的都是ns2。首先,ns1|2的意义是什么?我该如何解决这个问题?
第二个问题是有没有办法通过仅调用 SOAPHEADER() 一次来生成相同的结果?
Here's the code I'm using to generate the request headers:
$headers = array(
new SOAPHEADER($this->_ns,'username',$this->_username,false, $this->_actor),
new SOAPHEADER($this->_ns,'password',$this->_password,false, $this->_actor));
$this->_client->__setSOAPHeaders($headers);
This generates:
<SOAP-ENV:Header>
<ns2:username SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next">test</ns2:username>
<ns2:password SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next">test</ns2:password>
</SOAP-ENV:Header>
That's all fine and dandy.
Here are my two questions:
The API doc requires that username be ns1:username and password be ns2:password. Mine are both ns2. First of all, what is the significance of the ns1|2? How can I fix this?
Second question is just is there a way to generate the same result by only calling SOAPHEADER() once?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$this->_ns
时,它们当然是相同的。您必须自己提供正确的命名空间(前缀并不重要,uri 才重要)。$this->_ns
to both of them, of course they'll be the same. You'll have to provide the proper namespace yourself (prefix doesn't matter, uri does).