SoapClient: how to pass multiple elements with same name?(SoapClient:如何传递多个同名元素?)
问题描述
我有以下代码:
$telnums = array(10, 20, 30);
$obj = new StdClass();
$obj->telnums = new StdClass();
foreach ($telnums as $telnum) {
$obj->telnums = $telnum;
}
call_user_func(array($this->client, 'createDomain'), new SoapVar($obj, SOAP_ENC_OBJECT));
$this->client 是 SoapClient 类的一个实例.
There $this->client is an instance of SoapClient class.
它生成以下请求:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="...">
<SOAP-ENV:Body>
<ns1:createDomain>
<createDomainRequest>
<telnums>30</telnums>
</createDomainRequest>
</ns1:createDomain>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
但我需要
<createDomainRequest>
<telnums>10</telnums>
<telnums>20</telnums>
<telnums>30</telnums>
</createDomainRequest>
我如何才能做到这一点?
How I can achieve this?
P.S.: PHP 5.2.6-3ubuntu4.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan 6 2010 22:25:33)
P.S.: PHP 5.2.6-3ubuntu4.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan 6 2010 22:25:33)
提前致谢!
推荐答案
通过 extends SoapClient 修复它并覆盖 __doRequest() 方法,我在这里修改请求:http://www.php.net/manual/en/soapclient.dorequest.php#57995
Fixed it by extends SoapClient and overrides __doRequest() method where I modify request as descibed here: http://www.php.net/manual/en/soapclient.dorequest.php#57995
对我来说看起来很糟糕,但它就在这里,现在"有效.
Looks terrible for me, but it works "right here, right now".
这篇关于SoapClient:如何传递多个同名元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SoapClient:如何传递多个同名元素?


- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Laravel 仓库 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01