How do I turn on debugging? #
Client:
Set the debug_flag property to true, eg: $soapclient->debug_flag=true
Access the debug information via the debug_data property, eg: echo $soapclient->debug_data
Server:
Same as above. If debugging is on, the server will append the debug onto it's response, as a comment at the end of the message.
You can turn server debugging on via a client by appending "?debug=1" to the NuSOAP server endpoint URL. Again, the server will attach the debug log as a comment at the end of the SOAP response. [Note: some SOAP clients choke on this.]
How do I deploy a web service with NuSOAP? #
Here is a simple "hello world" example. First create file "hello.php."
Put nusoap.php in the same directory, or in your include directory, or enter
the path to them in the require_once() calls below. Then paste the code below
into the file. That's it!
require_once('nusoap.php');
$server = new soap_server;
$server->register('hello');
function hello ($name){
return "Hello $name.";
}
$server->service($HTTP_RAW_POST_DATA);
Accessing the service via a NuSOAP client:
require_once('nusoap.php');
$soapclient = new soapclient('http://yourdomain.com/hello.php');
echo $soapclient->call('hello',array('name'=>'dietrich'));
NuSoap Client Usage and Error Handling #
Every class in the nusoap toolkit uses a getError() method for error detection.
So to catch all errors, code like this:
$soapclient =& new soapclient(...etc);
if($err = $soapclient->getError()){
// handle error however
} else {
$return_val = $soapclient->call(...etc);
if($err = $soapclient->getError()){
// handle error however
} else {
// do something w/ return val
}
}
here's the best way to get the wire data, and debug log:
echo 'Request: <xmp>'.$soapclient->request.'</xmp>';
echo 'Response: <xmp>'.$soapclient->response.'</xmp>';
echo 'Debug log: <pre>'.$soapclient->debug_str.'</pre>';
