Home » Php, Webservice

Creating a php webservice for C#

12 June 2007 No Comment

Probably a lot of you are wonder if is possible to access a php webservice from C#, so I made a simple test to show you is possible :) .
In this test I used nusoap and php4. In the future I will do the test with PHP5 and it’s SOAP library.

//ws.php

require_once(“lib/nusoap.php”);
$ns=”http://your.server.address/”;

$param = array(‘x’ => ‘xsd:string’,'y’ => ‘xsd:string’);
$return = array(‘return’=>’xsd:string’);

$server = new soap_server();
$server->configureWSDL(‘WS Test’,$ns);
$server->wsdl->schemaTargetNamespace=$ns;
$server->register(‘TestFunction’,$param,$return,$ns);

function TestFunction($x,$y){

$ret=$x+$y;

return new soapval(‘return’,'xsd:string’,$ret);
}

$server->service($HTTP_RAW_POST_DATA);

To access this webservice just go to: http://your.server.address/ws.php?wsdl


Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.