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
https://forums.phpfreaks.com/topic/46041-consuming-net-web-service-in-php/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.