2

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

Community
  • 1
  • 1
  • 2
    possible duplicate of [Call asp.net web service from PHP with multiple parameters](http://stackoverflow.com/questions/9711502/call-asp-net-web-service-from-php-with-multiple-parameters) – Nikhil Vartak Sep 30 '15 at 10:31
  • possible duplicate of [how to call web services using soap in php](http://stackoverflow.com/questions/20118839/how-to-call-web-services-using-soap-in-php) – TZHX Sep 30 '15 at 10:31
  • @TZHX Don't take me wrong, but we should not suggest duplicates that have not been answered. Your link post is unsolved (at least it's not marked as answered by OP). – Nikhil Vartak Sep 30 '15 at 10:33
  • no it is not solved and my question is unique – Emad Morris Zedan Sep 30 '15 at 10:38
  • @vnikhil it has an upvoted answer that seems to work well enough -- but I agree your suggestion fits better. – TZHX Sep 30 '15 at 10:41
  • no it is not working – Emad Morris Zedan Sep 30 '15 at 11:03

1 Answers1

2

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;
?>