PHP SoapClient-_SoapCall必须在方法名称中包装参数

时间:2018-10-18 11:35:28

标签: php wsdl soap-client

我有以下肥皂网络服务:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
     <Customer_Get xmlns="http://example.com/">
       <token>string</token>
       <customerId>string</customerId>
     </Customer_Get>
   </soap:Body>
</soap:Envelope>

以下呼叫无效:

$soap = new SoapClient('link/to/.wsdl');
$result = $soap->__soapCall('Customer_Get', ['token' => 'asdad', 'customerId' => 1]);

但是,当我将参数数组包装在带有方法名称的数组中时,它将起作用:

$soap = new SoapClient('link/to/.wsdl');
$result = $soap->__soapCall('Customer_Get', ['Customer_Get' => ['token' => 'asdad', 'customerId' => 1]]); 

为什么需要在方法名称中包装参数?

1 个答案:

答案 0 :(得分:0)

因为这个电话

$result = $soap->__soapCall('Customer_Get', ['Customer_Get' => ['token' => 'asdad', 'customerId' => 1]]);

是此调用的简写(带有“参数”):

$result = $soap->__soapCall('Customer_Get', ['parameters' => ['Customer_Get' => ['token' => 'asdad', 'customerId' => 1]]]);