dongpo1846 2018-08-04 10:01
浏览 221
已采纳

在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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上