dongpo1846
2018-08-04 10:01
浏览 218

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

I have this xml call which working well in soap ui.

<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>

I don't understand how to build an array in php to male a call:

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

in $params should be an array in this specific format.

I tried this, but got the response from the server "Fault occurred while processing"

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

Help, please

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongzhu7329 2018-08-06 14:51
    已采纳

    So, I fix the array and it works

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

    Thanks to all

    打赏 评论

相关推荐 更多相似问题