Like this article? We recommend
Writing a Web Service Client
Writing a Web Service Client
After the web service server is completed and verified, you can write a NuSOAP web service client. This is easier than creating a server, as you will see in this section. You may notice that in the following listing that a client instance is created by instantiating the soapclientNusoap class; to call the web service method, you should use the NuSOAP call method.
><?php // Pull in the NuSOAP code require_once('./nusoap-php5-0.9/lib/nusoap.php'); // Create the client instance $client = new soapclientNusoap('http://localhost/php/SOAP_MESSAGES/server.php?wsdl', true); // Check for an error $err = $client->getError(); if ($err) { // Display the error echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; // At this point, you know the call that follows will fail } // Call the RectangleArea SOAP method $result = $client->call('RectangleArea', array('L' => 40, 'l' => 20)); // Check for a fault if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { // Check for errors $err = $client->getError(); if ($err) { // Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { // Display the result echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>'; } } ?>