Herong's Tutorial Notes on Web Service and SOAP
Dr. Herong Yang, Version 4.00

GetTemp.php - First Example with SOAP

This section describes a tutorial example, GetTemp.php, on how to use PHP SOAP client interface.

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
      ("http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl");
   echo("\nReturning value of getTemp() call: ".
      $client->getTemp("12345"));
?>

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.
  • Your PHP SOAP Extension is installed correctly and working.
  • PHP SOAP Extension supports WSDL.
  • www.xmethods.net is doing a great job for offering this demonstration SOAP service.

Last update: 2007.

Sections in This Chapter

What Is PHP SOAP Extension?

GetTemp.php - First Example with SOAP

PHP SOAP Extension Functions for Client Programs

GetTempDump.php - Dumping Debugging Information

Whis Is WSDL (Web Services Definition Language)?

Using SOAP Extension in non-WDSL Mode

Dr. Herong Yang, updated in 2009
GetTemp.php - First Example with SOAP