PHP Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 2.21

PHP SOAP Extension

Part:   1  2  3  4 

PHP Tutorials - Herong's Tutorial Notes © Dr. Herong Yang

Non ASCII Characters with MySQL

Inputting Non ASCII Characters

Controlling Response Header Lines

HTTP Request Variables


Using Cookies

PHP SOAP Extension

PHP SOAP Extension - Server

Directories, Files and Images

Using MySQL with PHP

... Table of Contents

This chapter describes:

  • What is PHP SOAP Extension?
  • My first example with SOAP Extension.
  • SOAP Extension functions for client applications.
  • How to dump detailed information for debugging.
  • A WSDL document example.
  • How use SOAP Extension in non-WSDL mode.

What Is PHP SOAP Extension?

PHP SOAP Extension is one of the most popular PHP implementations of SOAP 1.1 and 1.2, developed by The PHP Group.

What are the features of PHP SOAP Extension? I don't known. I tried to find the feature list on the Web, no success.

How to install PHP SOAP Extension? It is included in the PHP 5.0.4 package for Windows distributed by Zend Technologies. See previous notes on details of how to install the PHP package and the PHP SOAP Extension.

GetTemp.php - First Example with SOAP

To show you an example of how PHP SOAP Extension can be used in a SOAP client application, here is my first SOAP PHP program, GetTemp.php

<?php # GetTemp.php
# Copyright (c) 2005 by Dr. Herong Yang,
   $client = new SoapClient
   echo("\nReturning value of getTemp() call: ".

Run it while your connected to the Internet. You will get:

>php GetTemp.php

Returning value of getTemp() call: 52

Very nice. This confirms that:

  • PHP SOAP Extension is easy to use. Two statements are enough to call a SOAP service.
  • You PHP SOAP Extension is installed correctly and working.
  • PHP SOAP Extension supports WSDL.
  • is doing a great job for offering this demonstration SOAP service.

PHP SOAP Extension Functions for Client Applications

If you read the SOAP Extension reference page, you will see that SOAP Extension support SOAP client applications with a class called SoapClient, which offers the following functions:

  • SoapClient->__construct() - constructs a new SoapClient object
  • SoapClient->__soapCall() - Calls a SOAP function
  • SoapClient->__getFunctions() - Returns list of SOAP functions
  • SoapClient->__getLastRequestHeaders() - Returns last SOAP request headers
  • SoapClient->__getLastRequest() - Returns last SOAP request
  • SoapClient->__getLastResponseHeaders() - Returns last SOAP response headers
  • SoapClient->__getLastResponse() - Returns last SOAP response
  • ...

SoapClient->__construct() allows you to construct a new SoapClient object with the following syntax:

   __construct ( mixed wsdl [, array options] );

where "wsdl" specifies the URL of the WSDL document, and "options" specifies a list of options:

   'location'     => "...", # the URL where to send the request
   'uri'          => "...", # the name space of the SOAP service
   'soap_version' => SOAP_1_1 |SOAP_1_2,
   'trace'        => 0 | 1,

(Continued on next part...)

Part:   1  2  3  4 

Dr. Herong Yang, updated in 2006
PHP Tutorials - Herong's Tutorial Notes - PHP SOAP Extension