PHP web serivce and .NET client

Lately I decided to have some investigation into PHP and .NET web service interoperability for one of my projects. NuSOAP turned out to be very handy.

As a first step I decided to build a PHP web service:

include("lib/nusoap.php");

function Add($a, $b)
{
return $a + $b;
}

$server = new soap_server;

$server->configureWSDL("MathWebService","http://tempuri.org", "", "document");

$server->register("Add", array("a"=>"xsd:int", "b"=>"xsd:int"), array("return"=>"xsd:int"));

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';

$server->service($HTTP_RAW_POST_DATA);

exit;

The line containing configureWSDL is VERY important as .NET client expects web service to return document style formated response. NuSOAP by default sets style to rpc, which causes some strange exceptions on the client.

Now the client was easy just add web reference some buttons.

All of it was tested on VS 2005.

The one feature that's quite important for me, but lacks support in nuSOAP is message body encryption. It may be useful for calling non public highly sensitive web services. Though nuSOAP supports tunneling through SSL it is not a desired solution for me.