PHP Modules Tutorials - Herong's Tutorial Examples - v5.18, by 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 2009-2015 (c) HerongYang.com. All Rights Reserved.
#
$client = new SoapClient(null, array(
'location' =>
"https://www.herongyang.com/Service/Hello_SOAP_11.php",
'uri' => "https://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) "https://www.herongyang.com/Service/"
["location"]=>
string(51) "https://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
Content-Type: text/xml; charset=utf-8
SOAPAction: "https://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/"
xmlns:ns1="https://www.herongyang.com/Service/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:Hello/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Dumping response headers:
HTTP/1.1 200 OK
Server: Apache
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="https://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:
Table of Contents
Introduction and Installation of PHP
Managing PHP Engine and Modules on macOS
Managing PHP Engine and Modules on CentOS
DOM Module - Parsing HTML Documents
GD Module - Manipulating Images and Pictures
MySQLi Module - Accessing MySQL Server
OpenSSL Module - Cryptography and SSL/TLS Toolkit
PCRE Module - Perl Compatible Regular Expressions
►SOAP Module - Creating and Calling Web Services
SOAP Module and PHP Implementations of SOAP
Turning on the Default SOAP Module
Hello_There.php - First Example of SOAP
SoapClient - SOAP Client Class and Functions
Hello_There_Dump.php - Debugging SOAP Messages
►Using SOAP Extension in non-WSDL Mode
SOAP Module - Server Functions and Examples