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

Using SOAP Extension in non-WSDL Mode

This section provides a tutorial example on how to use SOAP client functions to make Web service call without using the WSDL standard on the target SOAP node and print detailed debug information.

I think we had enough fun with the WSDL mode. Let's try the non-WSDL mode now. Here is the third version of my Get_Temperature.php SOAP client program, Hello_There_Non_WSDL.php:

<?php # Hello_There_Non_WSDL.php
#- Copyright (c) 2015, HerongYang.com, All Rights Reserved.
#
   $client = new SoapClient(null, array(
      'location' => 
         "http://www.herongyang.com/Service/Hello_SOAP_11.php",
      'uri'      => "http://www.herongyang.com/Service/", 
      'trace'    => 1 ));

   echo("\nDumping client object:\n");
   var_dump($client);

   $return = $client->__soapCall("Hello",array());
   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 (4) {
  ["uri"]=>
  string(34) "http://www.herongyang.com/Service/"
  ["location"]=>
  string(51) "http://www.herongyang.com/Service/Hello_SOAP_11.php"
  ["trace"]=>
  int(1)
  ["_soap_version"]=>
  int(1)
}

Returning value of __soapCall() call:
Dumping request headers:
POST /Service/Hello_SOAP_11.php HTTP/1.1
Host: www.herongyang.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.6.6
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.herongyang.com/Service/#Hello"
Content-Length: 399


Dumping request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xm
lns:ns1="http://www.herongyang.com/Service/" xmlns:xsd="http://www.w3.org/2001/X
MLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:en
codingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:Hell
o/></SOAP-ENV:Body></SOAP-ENV:Envelope>

Dumping response headers:
HTTP/1.1 200 OK
Server: Apache
X-Powered-By: PHP/5.5.22
Keep-Alive: timeout=2, max=200
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/xml

Dumping response:
<soapenv:Envelope
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:hy="http://www.herongyang.com/Service/">
  <soapenv:Header/>
  <soapenv:Body>
    <hy:HelloResponse>
      Hello from server - herongyang.com.
    </hy:HelloResponse>
  </soapenv:Body>
</soapenv:Envelope>

The output shows that:

  • My Hello_There_Non_WSDL.php works the same as the WSDL mode version.
  • If you compare this output with the WSDL output, SOAP Extension generates the request headers with one difference: SOAPAction is not blank any more. It has the value of "http://www.herongyang.com/Service/#Hello".

Last update: 2015.

Table of Contents

 About This PHP Tutorial Book

 Introduction and Installation of PHP 5.6.6

 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

 Hello_There.php - First Example of SOAP

 SoapClient - SOAP Client Class and Functions

 Hello_There_Dump.php - Debugging SOAP Messages

 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

 Introduction of Class and Object

 Outdated Tutorials

 References

 PDF Printing Version

Using SOAP Extension in non-WSDL Mode - Updated in 2015, by Dr. Herong Yang