0

当我用 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;
    }
)
4

1 回答 1

2

addResponse只需要一个参数,因此您需要将其传递到数组或对象中:

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

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

$result = $client->add($params);
于 2012-12-02T17:33:53.140 回答