PHP - 如何从对象生成Soap请求XML

时间:2012-12-11 07:47:47

标签: php xml soap request

我有一个std对象:

$args = new stdClass();
$args->userName = 'username';
$args->password = 'password';
$args->criteria->customer->customerId = '0002003';

我想创建SoapRequest XML:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="wsclient.dms.tecsys.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Body>
        <mns1:search xmlns:mns1="wsclient.dms.tecsys.com">
            <arg0>
                <userName>username</userName>
                <password>password</password>
                <criteria>
                   <customer>
                      <customerId>0002003</customerId>
                   </customer>
                </criteria>
            </arg0>
        </mns1:search>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

但我无法找到解决方案。谁能帮我。 此致

1 个答案:

答案 0 :(得分:1)

通过使用SoapClient类,您可以轻松创建soap请求

看看这个

SoapClient:__ doRequest - 执行SOAP请求