Jump to content

Consuming .Net Web service in PHP


lubasi

Recommended Posts

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!!! ;D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.