Tuesday, April 14, 2009

Consuming ASP.NET webservice through PHP

I am trying to get least familiar with PHP code.I tried this simple asp.net webservice which is going to be consumed through PHP.

My asp.net code snippet
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld(string name) {
return "Hello " + name;

}

}
_________________________________________________________________________

PHP
_________________________________________________________________________

require_once('lib/nusoap.php');
$objClient = new soapclient("http://localhost/website1/Service.asmx?WSDL");
$result = $objClient->call("HelloWorld", array('name' => 'Murugesan'));
echo $result;
?>

After i tried neckling fight with PHP code,I did not get my code works as I expected.
I keep my fingers cross over where I am doing wrong.