Nusoap Web Service Arrays (2)
Previous entire review hello.php .The client changes only in that it passes a parameter that is an array of names, rather than a single scalar name.
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/nusoap/hello.php');
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '
Constructor error: ‘ . $err . ‘
‘;
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$names = array(’Scott’, ‘Albert’, ‘Robert’, ‘Phyllis’);
$result = $client->call(
‘hello’, // method name
array(’names’ => $names) // input parameters
);
// Check for a fault
if ($client->fault) {
echo ‘
Fault: ‘;
print_r($result);
echo ‘
‘;
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo ‘
Error: ‘ . $err . ‘
‘;
} else {
// Display the result
print_r($result);
}
}
?>
February 1st, 2008 at 3:44 pm
[…] continuous to view helloclient.php […]