为PHP 7中的SoapClient调用生成一个数组

时间:2018-08-04 10:01:19

标签: php arrays xml soap call

我有这个可以在soap ui中正常工作的xml调用。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
    <globalSearch xmlns="http://v4.websvc.customer.com/">
            <arg0 xsi:type="ns1:searchCriteriaDTO" xmlns=""
                xmlns:ns1="http://v4.websvc.customer.com/">
                <name xsi:type="xsd:string">bouwy</name>
                <firstName xsi:type="xsd:string"></firstName>
                <postalCode xsi:type="xsd:string"></postalCode>
                <cityOrProvince xsi:type="xsd:string">lens</cityOrProvince>
                <country xsi:type="xsd:string">UA</country>
                <buNumber xsi:type="xsd:int">023</buNumber>
                <maxNumberOfResults xsi:type="xsd:int">30
                </maxNumberOfResults>
                <detailedSearch xsi:type="xsd:boolean">true</detailedSearch>
                <deletedAlso xsi:type="xsd:boolean">false</deletedAlso>
            </arg0>
    </globalSearch>
</soapenv:Body>

我不明白如何在php中建立一个数组以发出呼叫:

$soap = new SoapClient($wsdl, $options);
$data = $soap->globalSearch($params);
$ params中的

应该是此特定格式的数组。

我尝试了此操作,但收到了服务器的响应“处理过程中发生了故障”

$params = array (
    'arg0' => array (
     'name' => 'bouwy',
     'firstName' => '',
     'postalCode' => '',
     'cityOrProvince' => 'lens',
     'country' => 'UA',
     'buNumber' => '023',
     'maxNumberOfResults ' => '30',
     'detailedSearch ' => 'true',
     'deletedAlso' => 'false'
     )
    );

请帮助

1 个答案:

答案 0 :(得分:0)

因此,我修复了阵列,它可以正常工作

$params = array (
'arg0' => array (
'searchCriteriaDTO' => '',
 'name' => 'bouwy',
 'firstName' => '',
 'postalCode' => '',
 'cityOrProvince' => 'lens',
 'country' => 'UA',
 'buNumber' => '023',
 'maxNumberOfResults ' => '30',
 'detailedSearch ' => 'true',
 'deletedAlso' => 'false',
 'any' => ''
 )
);

感谢所有人