PHP - 使用 SoapClient 创建嵌套 Soap 标头
我正在 PHP 中使用 SoapClient
类来发出请求。我正在尝试创建一个嵌套标头变量来传递我的请求。
目前我的请求标头看起来像这样,
<SOAP-ENV:Header>
<ns2:type>request</ns2:type>
...
</SOAP-ENV:Header>
我希望它看起来像这样,
<SOAP-ENV:Header>
<ns2:ei>
<ns2:type>request</ns2:type>
...
</ns2:ei>
</SOAP-ENV:Header>
我当前正在创建这样的标头,
$headers[] = new SoapHeader(
$nsp1,
"type",
"request"
);
$headers[] = new SoapHeader(...)
我尝试了各种方法来嵌套标头,
$headers[] = new SoapHeader(
$nsp1,
"ei",
new SoapHeader(
$nsp1,
"type",
"request"
)
);
但这会引发致命错误。
I am using the SoapClient
class in PHP to make a request. I am trying to create a nested header variable to pass in my request.
Currently my request headers looks like this,
<SOAP-ENV:Header>
<ns2:type>request</ns2:type>
...
</SOAP-ENV:Header>
I want it to look like this,
<SOAP-ENV:Header>
<ns2:ei>
<ns2:type>request</ns2:type>
...
</ns2:ei>
</SOAP-ENV:Header>
I am currently creating the headers like this,
$headers[] = new SoapHeader(
$nsp1,
"type",
"request"
);
$headers[] = new SoapHeader(...)
I have tried various ways to nest the headers the including,
$headers[] = new SoapHeader(
$nsp1,
"ei",
new SoapHeader(
$nsp1,
"type",
"request"
)
);
but this throws a fatal error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用对象或数组作为 $data 参数
Object:
Gives
Array:
Gives
You can try using an object or an array as the $data parameter
Object:
Gives
Array:
Gives
您无法创建嵌套实例,您可以尝试类似的方法
You can't create nested instance, you can try something like these