我以这种方式向WSDL
服务器发送请求:
$soap = new SoapClient('WSDL_URI');
$soap->SomeFunction(array('Param1' => 123, 'Param2' => 456));
它工作正常,__getLastRequest
返回:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:SomeFunction>
<ns1:Param1>123</ns1:Param1>
<ns1:Param2>456</ns1:Param2>
</ns1:SomeFunction>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
但如果我在SomeFunction
之前致电__soapCall
,则WSDL
服务器会停止响应并且不会返回正确的回复。
$soap->__soapCall('SomeFunction', array('Param1' => 123, 'Param2' => 456));
__getLastRequest
返回:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:SomeFunction/>
<param1>123</param1>
<param2>456</param2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
你知道,因为请求不同,它不起作用..
如何解决?
答案 0 :(得分:6)
如php文档中所示SoapClient::__soapCall,
$client = new SoapClient("some.wsdl");
$client->SomeFunction($a, $b, $c);
// Or
$client->__soapCall("SomeFunction", array($a, $b, $c));
所以我想如果你想用__soapCall
打电话给网络服务,你应该这样打电话:
$soap->__soapCall('SomeFunction', array(array('Param1' => 123, 'Param2' => 456)));