2

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>

但是如果我调用SomeFunctionby __soapCallWSDL服务器会停止并且不会返回正确的响应。

$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>

你看,因为请求不同,它不起作用..

如何解决?

4

1 回答 1

7

如 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)));
于 2012-08-17T16:54:23.590 回答