PHP Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 3.10

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());
?>

If you run this sample script, you will get:

Dumping client object:
object(SoapClient)#1 (3) {
  ["trace"]=>
  int(1)
  ["_soap_version"]=>
  int(1)
  ["sdl"]=>
  resource(5) of type (Unknown)
}

Dumping client object functions:
array(1) {
  [0]=>
  string(30) "float getTemp(string $zipcode)"
}

Returning value of getTemp() call: 52

Returning value of __soapCall() call: 52

Dumping request headers:
POST /soap/servlet/rpcrouter HTTP/1.1
Host: services.xmethods.net
Connection: Keep-Alive
User-Agent: PHP SOAP 0.1
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 510
Cookie: JSESSIONID=uuqkGDvtzw_IPlMLsodnVX9j;

Dumping request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
 xmlns:ns1="urn:xmethods-Temperature-Demo" 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body><ns1:getTemp>
  <zipcode xsi:type="xsd:string">123456</zipcode>
 </ns1:getTemp></SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Dumping response headers:
HTTP/1.1 200 OK
Server: Enhydra-MultiServer/3.1.1b1
Status: 200
Content-Type: text/xml; charset=utf-8
Servlet-Engine: Enhydra Application Server/3.1.1b1 (JSP 1.1; 
   Servlet 2.2; Java 1.4.2_03; Linux 2.4.7-10smp i386; 
   java.vendor=Sun Microsystems Inc.)
Content-Length: 470
X-Cache: MISS from www.xmethods.net
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive

Dumping response:
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope 
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getTempResponse xmlns:ns1="urn:xmethods-Temperature-Demo" 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:float">52.0</return>
</ns1:getTempResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The output is very useful. It confirms that:

  • 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".

Last update: 2005.

Table of Contents

 About This PHP Tutorial Book

 Introduction and Installation of PHP 5.4.3

 PHP Script File Syntax

 PHP Data Types and Data Literals

 Variables, References, and Constants

 Expressions, Operations and Type Conversions

 Conditional Statements - "if" and "switch"

 Loop Statements - "while", "for", and "do ... while"

 Function Declaration, Arguments, and Return Values

 Arrays - Ordered Maps

 Configuring and Sending out Emails

 Retrieving Information from HTTP Requests

 Creating and Managing Sessions in PHP Scripts

 Sending and Receiving Cookies in PHP Scripts

 Controlling HTTP Response Header Lines in PHP Scripts

 MySQL Server Connection and Access Functions

 Functions to Manage Directories, Files and Images

SOAP Extension Function and Calling Web Services

 PHP Implementations of SOAP

 Turning on the Default SOAP Extension

 Get_Temperature.php - First Example of SOAP

 SoapClient - SOAP Client Class and Functions

Get_Temperature_Dump.php - Dumping Debugging Information

 What Is WSDL?

 Using SOAP Extension in non-WSDL Mode

 SOAP Server Functions and Examples

 Localization Overview of Web Applications

 Using Non-ASCII Characters in HTML Documents

 Using Non-ASCII Characters as PHP Script String Literals

 Receiving Non-ASCII Characters from Input Forms

 "mbstring" Extension and Non-ASCII Encoding Management

 Managing Non-ASCII Character Strings with MySQL Servers

 Outdated Tutorials

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2012
Get_Temperature_Dump.php - Dumping Debugging Information