SoapClient:如何传递多个具有相同名称的元素? [英] SoapClient: how to pass multiple elements with same name?

查看:93
本文介绍了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>

我该如何实现?

P.S .: PHP 5.2.6-3ubuntu4.5 with Suhosin-Patch 0.9.6.2(cli)(build:2010年1月6日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)

提前谢谢!

推荐答案

通过扩展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:如何传递多个具有相同名称的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆