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

Sessions

Using Cookies

PHP SOAP Extension

PHP SOAP Extension - Server

Directories, Files and Images

Using MySQL with PHP

... Table of Contents

(Continued from previous part...)

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

Whis Is WSDL?

WSDL (Web Services Definition Language): An XML based standard designed to describes protocol bindings and message formats of Web services. WSDL is often pronounced as "Whiz-Dull".

A WSDL document is an XML document written in WSDL to describe Web service. Here is a copy of the WSDL document for the demonstration Web service used in previous sections. You can download one yourself by going to http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl with your Web browser:

<?xml version="1.0"?>
<definitions name="TemperatureService" 
 targetNamespace="http://www.xmethods.net/sd/TemperatureService.wsdl"
 xmlns:tns="http://www.xmethods.net/sd/TemperatureService.wsdl"   
 xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
 xmlns="http://schemas.xmlsoap.org/wsdl/">
 <message name="getTempRequest">
  <part name="zipcode" type="xsd:string"/>
 </message>
 <message name="getTempResponse">
  <part name="return" type="xsd:float"/>
 </message>
 <portType name="TemperaturePortType">
  <operation name="getTemp">
   <input message="tns:getTempRequest"/>
   <output message="tns:getTempResponse"/>
  </operation>
 </portType>
 <binding name="TemperatureBinding" type="tns:TemperaturePortType">
  <soap:binding style="rpc"
   transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="getTemp">
   <soap:operation soapAction=""/>
   <input>
    <soap:body use="encoded"
     namespace="urn:xmethods-Temperature-Demo"
     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
   </input>
   <output>
    <soap:body use="encoded"
     namespace="urn:xmethods-Temperature-Demo"
     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
   </output>
  </operation>
 </binding>
 <service name="TemperatureService">
  <documentation>Returns current temperature in a given U.S. zipcode
  </documentation>
  <port name="TemperaturePort" binding="tns:TemperatureBinding">
   <soap:address
  location="http://services.xmethods.net:80/soap/servlet/rpcrouter"/>
  </port>
 </service>
</definitions>

I cannot read this document well before learning the WSDL specifications. But it seems to be describing precisely how this Web service should be used.

(Continued on next part...)

Part:   1  2  3  4 

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