Reputation: 301
I have this ASP.Net C# Web Service http://www.emadbook.com/TestWebService/Convert.asmx
and this is the PHP client code:
<?php
//Use C# Web Service:
require "lib/nusoap.php";
$client2 = new nusoap_client("http://www.emadbook.com/TestWebService/Convert.asmx?WSDL","http://tempuri.org/");
$result = $client2->call("CelsiusToFahrenheit", array(37));
echo $result;
?>
this code return nothing and no errors anybody can modify my code to return a value, I think the main error is in passing a number to the service as I looked on google but I could not find a way of sending number parameter?
Edit: I saw this link: Call asp.net web service from PHP with multiple parameters and I modified my code to:
<?php
//Use C# Web Service:
$client2 = new SoapClient("http://www.emadbook.com/TestWebService/Convert.asmx?WSDL");
$params->Celsius = '37';
$result = $client2->CelsiusToFahrenheit($params)->CelsiusToFahrenheitResult;
echo (string)$result;
?>
and it return a result but before that it show this error: Warning: Creating default object from empty value pointing to the Params variable creation, so this is good progress but any body can solve the generated error? thanks
Upvotes: 2
Views: 2072
Reputation: 301
This is the right Answer I found it by myself and I like to share it for other developers
<?php
//Use C# Web Service:
$client2 = new SoapClient("http://www.emadbook.com/TestWebService/Convert.asmx?WSDL");
$params = new ArrayObject();
$params->Celsius = 37;
$result = $client2->CelsiusToFahrenheit($params)->CelsiusToFahrenheitResult;
echo $result;
?>
Upvotes: 2