PHP + NuSoap: Calling webservice
December 20th, 2008
In the last post i made an implementation example of a small webservice.
Now we see how to invoke it with few line of code, using the same library used to realize the server side implementation.
In this example I want to display also all debug informations.
MyWebServiceClient.php
-
-
require_once('nusoap.php');
-
-
// Creating client instance
-
$client = new soapclient('http://www.miosito.com/MyWebService.php');
-
//Invoke remote method
-
$result = $client->call('MyMethod',
-
array('param1' => 'Ciao ', 'param2' => 'a tutti'));
-
//Display the result
-
print_r($result);
-
-
// Display all request and response information for debug purpose
-
echo '<h2>Request</h2>';
-
echo '<code>'.htmlspecialchars($client->request, ENT_QUOTES) .'</code>';
-
-
echo '<h2>Response</h2>';
-
echo '<code>'.htmlspecialchars($client->response, ENT_QUOTES) .'</code>';
All done! In this way we can invoke the webservice realized in the last post. It’s easy, isn’t it?






Recent Comments