Hello World Clients with PHP

Tuesday, January 29, 2008

Yesterday I gave you the sources for the services. Here are the Web service clients.

With SOAP Extension:
<?php   
$client = new SoapClient(null, array('location' => "http://localhost:9090/soap_ext/hw_service.php",
'uri' => "http://test-uri/"));
$result =  $client->__soapCall('hello', array('name' => 'Sam'));
printf($result);
?>

With NuSOAP:
<?php
require_once('../lib/nusoap.php');
$client = new soapclient('http://localhost:9090/nusoap-0.7.3/samples/hw_service.php');
$result = $client->call('hello', array('name' => 'Sam'));
printf($result);
?>

With WSF/PHP:
<?php   
$reqestPayloadString = <<<XML
<hello>
<name>Sam</name>
</hello>

XML;
$client = new WSClient(array("to" => "http://localhost:9090/tutorial/hello/hw_service.php"));   
$response = $client->request($reqestPayloadString);   
$simplexml = new SimpleXMLElement($response->str);
$result = $simplexml->return[0];   
printf($result);   
?>  

1 comment:

Jane B said...

Nice code examples.... thanks for sharing...

dot net web services