With SOAP extension:
<?php
function hello($param) {
$retval = 'Hello, '.$param;
return $retval;
}
$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->addFunction('hello');
$server->handle();
?>
With NuSOAP:
<?php
require_once('../lib/nusoap.php');
$server = new soap_server;
$server->register('hello');
function hello($name) {
return 'Hello, ' . $name;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
With WSF/PHP:
<?php
function hello($message) {
$simplexml = new SimpleXMLElement($message->str);
$name = $simplexml->name[0];
$responsePayloadString = <<<XML
<helloResponse>
<return>Hello, $name</return>
</helloResponse>
XML;
return $responsePayloadString;
}
$service = new WSService(array("operations" => array("hello")));
$service->reply();
?>
3 comments:
In nusoap web service why you register service it can?
I have a problem. if i want to select data from database that can contain more one result i try it can't return in in row because not have type that support how should i do?
register in nuSOAP is used for specify the service operation..
If you want to return several rows of data you have to wrap it with a root xml element.
i.e. your message would be like,
<mymessage>
<row1>value1</row1>
<row2>vallu2</row2>
</mymessage>
Post a Comment