Php SoapClient没有返回它应该返回的结果

Php SoapClient没有返回它应该返回的结果,php,soap,soapui,soap-client,Php,Soap,Soapui,Soap Client,当我用SoapUI测试这个WSDL时,我得到了真正的结果,它只是增加了数字: $client = new SoapClient("http://localhost:8080/calculator?wsdl"); $result = $client->add(3,3); print_r($result); 这将返回: stdClass Object ( [return] => 0 ) 但是应该返回6。就像在SoapUI中一样 一些调试: print_r($client-

当我用SoapUI测试这个WSDL时,我得到了真正的结果,它只是增加了数字:

$client = new SoapClient("http://localhost:8080/calculator?wsdl");

$result = $client->add(3,3);

print_r($result);
这将返回:

stdClass Object
(
    [return] => 0
)
但是应该返回6。就像在SoapUI中一样

一些调试:

print_r($client->__getFunctions());
print_r($client->__getTypes());

Array
(
    [0] => addResponse add(add $parameters)
)
Array
(
    [0] => struct add {
         int arg0;
         int arg1;
    }
    [1] => struct addResponse {
         int return;
    }
)

addResponse
只需要一个参数,所以您需要在数组或对象中传递它:

$params = array(
    'arg0' => 3,
    'arg1' => 3
);

//OR
//$params = new stdClass;
//$params->arg0 = 3;
//$params->arg1 = 3;

$result = $client->add($params);

实例化
SoapClient
,将
trace
选项设置为true,并比较
$client->\uu getLastRequest()使用soapui发送的xml。使用nusoap:)最终您将不得不这样做。