∟Get_Temperature_Dump.php - Dumping Debugging Information
This section provides a tutorial example on how to use SOAP client functions to make Web service call on the target SOAP node and print detailed debug information.
After learning the basic functions of the SoapClient class, I revised my Get_Temperature.php client program to
get more information on how SOAP Extension works, and to show you how to debug a SOAP client program.
The new client program is called, Get_Temperature_Dump.php:
<?php # Get_Temperature_Dump.php
# Copyright (c) 2005 by Dr. Herong Yang
#
$zip = "123456";
$client = new SoapClient
("http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl",
array('trace' => 1));
echo("\nDumping client object:\n");
var_dump($client);
echo("\nDumping client object functions:\n");
var_dump($client->__getFunctions());
$return = $client->getTemp($zip);
echo("\nReturning value of getTemp() call: ".$return);
$return = $client->__soapCall("getTemp",array($zip));
echo("\nReturning value of __soapCall() call: ".$return);
echo("\nDumping request headers:\n"
.$client->__getLastRequestHeaders());
echo("\nDumping request:\n".$client->__getLastRequest());
echo("\nDumping response headers:\n"
.$client->__getLastResponseHeaders());
echo("\nDumping response:\n".$client->__getLastResponse());
?>
The default SOAP version is SOAP 1.1. For SOAP 1.2, the envelope namespace should be
http://www.w3.org/2003/05/soap-envelope, not http://schemas.xmlsoap.org/soap/envelope/.
The transportation protocol is HTTP/1.1. See the request header lines.
There is only one RPC function supported in this WSDL: "float getTemp(string $zipcode)".
See the __getFunctions() dump.
SOAP Extension converts my getTemp() RPC call nicely in a SOAP request message based on
the definitions in the WSDL document.
The returning value is also converted properly into a "float" type of value, not a "string".
The SOAP response message shows "52.0", but the print out of $return is "52".