lubasi Posted April 7, 2007 Share Posted April 7, 2007 Am trying to consume a web service in ASP.NET in my PHP code as follows: ASP.NET Web service Code: namespace TempConvert1 { [system.Web.Services.WebService( Namespace="http://Walkthrough/XmlWebServices/", Description="A temperature conversion service.")] public class Service1 : System.Web.Services.WebService { public Service1() { //CODEGEN: This call is required by the ASP.NET Web Services Designer InitializeComponent(); } private void InitializeComponent() { } protected override void Dispose( bool disposing ) { if(disposing && components != null) { components.Dispose(); } base.Dispose(disposing); } [WebMethod(Description="This method converts a temperature in " + "degrees Fahrenheit to a temperature in degrees Celsius.")] public double ConvertTemperature(double dFahrenheit) { return ((dFahrenheit - 32) * 5) / 9; } } } and am consuming this Web service in PHP as follows: <?php require_once('lib/nusoap.php'); $client = new soapclient('http://192.168.1.66/TempConvert1/Service1.asmx?wsdl','wsdl'); $client->debug_flag = true; $param = array('dFahrenheit'=>200); $result = $client->call('ConvertTemperature', $param); echo "The message is: $result"; ?> The problem am getting is that the out is "Array", and when i replace the output with print_r($result); Am getting this output which is correct but with other things which i dont want Array ( [ConvertTemperatureResult] => -17.777777777777779 ) My proble is how do i output only : -17.777777777777779 without the other staff. I'm really stack dont know what to do next. Lubasi ??? Quote Link to comment Share on other sites More sharing options...
redking Posted April 7, 2007 Share Posted April 7, 2007 $result = $client->call('ConvertTemperature', $param); echo "The message is: " . $result['ConvertTemperatureResult']; Quote Link to comment Share on other sites More sharing options...
lubasi Posted April 8, 2007 Author Share Posted April 8, 2007 Ooooh thanks. On more thing, in an event that i want to display a list of values from a similar web service, how do i display them in web service client in PHP? this makes me more confused cause looks like i have an array of arrays? Please help. Quote Link to comment Share on other sites More sharing options...
lubasi Posted April 8, 2007 Author Share Posted April 8, 2007 In addition, my client is unable to pass the variable to the .Net web service. What could be the problem? $param = array('dFahrenheit'=>200); $result = $client->call('ConvertTemperature', $param); so 200 is not being passed. Quote Link to comment Share on other sites More sharing options...
lubasi Posted April 8, 2007 Author Share Posted April 8, 2007 Problem resolve. for .Net C# in the nusoap client do write code as follows: $param = array('dFahrenheit'=>200); $result = $client->call('ConvertTemperature', array('parameters'=>$param)); Presto!! thanks for all your help, member of this board for life now!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.