問題描述
我有以下代碼:
$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:如何傳遞多個同名元素?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!