0

I'm trying to consume an ASP.Net web service using a php client. The php method recieves one double parameter and returns a value based on it.

This is my client.php code:

$wsdl_url = "url";
$client = new SoapClient($wsdl_url);
$params = array('value'=>200);
$response  = $client->kilogramsToPounds($params);
echo "<pre>";
var_dump($response);
echo "</pre>";
echo "$response->kilogramsToPoundsResult";

When I run the code I get the following error:

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'kilograms' property in /var/www/student/oce1bct/CourseWork/Scenario3/TestFolder/convertersTest.php:23 Stack trace: #0 /var/www/student/oce1bct/CourseWork/Scenario3/TestFolder/convertersTest.php(23): SoapClient->__call('kilogramsToPoun...', Array) #1 /var/www/student/oce1bct/CourseWork/Scenario3/TestFolder/convertersTest.php(23): SoapClient->kilogramsToPounds(Array) #2 {main} thrown in /var/www/student/oce1bct/CourseWork/Scenario3/TestFolder/convertersTest.php on line 23 

The excerpt from the web service to be consumed is also below

[WebMethod]

public double kilogramsToPounds(double kilograms)

{

double pounds = 0;

pounds = kilograms * 2.204;

return pounds;

}

I am 90% certain that I am not passing the values to the web service call correctly but have been unable to rectify the problem. Any help would be appreciated. Thanks.

4

1 回答 1

2

而不是这个

$params = array('value'=>200); 

利用

$params = array('kilograms'=>200); 
于 2012-05-17T20:41:20.897 回答