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.

1 Answer 1

1

Instead of this

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

use

$params = array('kilograms'=>200); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.