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

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

报告相同问题?

悬赏问题

  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动