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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算