2012-12-02 109 views
0

當我測試這個WSDL用了SoapUI,然後我得到真正的結果,它只是增加了數字:SoapClient的不返回結果它應該

$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; 
    } 
) 
+0

實例化'SoapClient'用'trace'選項設置爲true ,並比較'$ client - > __ getLastRequest();'用soapui發送的xml。 –

+0

使用nusoap :)最終你將不得不反正。 – povilasp

回答

2

addResponse預計公司只有一個參數,所以你需要將它傳遞數組或對象:

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

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

$result = $client->add($params); 
相關問題