Chapter 7. Web Service consumer 147
timeResponse = theTPFTimeService.getTime(new GetTimeRequestMessage());
System.out.println("TPF Time is: " + timeResponse.getHour() + ":" +
timeResponse.getMinute() + ":" + timeResponse.getSecond());
} catch(Exception e) {
System.out.println(“An error occurred while retrieving the z/TPF system
time);
e.printStackTrace();
}
}
}
7.3 Web Service consumer with PHP
PHP is a Web centric scripting language which has become quite powerful in recent years
and a large number of Web Applications are based on it or at least utilize it for their
presentation layer.
PHP 5 includes a SOAP library that makes it very easy to use Web Services over SOAP and
below. We show you just how easy it is to use our z/TPF base time service from within a PHP
scripted Web Page.
7.3.1 Enable PHP on a Web server
PHP is released under its own open source license, PHP license 3.1. Source packages for
the PHP runtime can be obtained from the official PHP Web site at:
http://www.php.net/
There are quite a few companies supporting PHP and distributing pre-compiled PHP
packages for several platforms. Among those companies, Zend Technologies Ltd is one of the
biggest supported behind PHP and they have several pre-compiled packages available that
work well in conjunction with IBM Servers and databases.
It is outside of the scope of this book to explain how to install and enable PHP on a Web
Server, but we refer you to the following book, which provides a lot more detail: Developing
PHP Applications for IBM Data Servers, SG24-7218.
Additional resources are readily available on the Internet as well.
7.3.2 Getting the WSDL
As a starting point for our development we require the WSDL document for the z/TPF based
time service again. We had used the same WSDL document previously to create the JSP
client, and we provide its source code in Example 7-6 for easier referencing.
Example 7-6 WSDL document
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://9.57.13.211/getTime"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TPFService"
targetNamespace="http://9.57.13.211/getTime"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
148 z/TPF and WebSphere Application Server in a Service Oriented Architecture
<xsd:schema elementFormDefault="unqualified"
targetNamespace="http://9.57.13.211/getTime"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://9.57.13.211/getTime">
<xsd:complexType name="GetTimeResponseMessage">
<xsd:sequence>
<xsd:element name="Hour" type="xsd:string"></xsd:element>
<xsd:element name="Minute" type="xsd:string"></xsd:element>
<xsd:element name="Second" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="GetTimeRequestMessage">
</xsd:complexType>
<xsd:element name="GetTimeRequest"
type="tns:GetTimeRequestMessage"></xsd:element>
<xsd:element name="GetTimeResponse"
type="tns:GetTimeResponseMessage"></xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetTimeRequest">
<wsdl:part name="GetTimeRequest" element="tns:GetTimeRequest"></wsdl:part>
</wsdl:message>
<wsdl:message name="GetTimeResponse">
<wsdl:part name="GetTimeResponse" element="tns:GetTimeResponse"></wsdl:part>
</wsdl:message>
<wsdl:portType name="TimePort">
<wsdl:operation name="GetTime">
<wsdl:input message="tns:GetTimeRequest"></wsdl:input>
<wsdl:output message="tns:GetTimeResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TimePortBinding" type="tns:TimePort">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
<wsdl:operation name="GetTime">
<soap:operation soapAction="getTime" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TPFService">
<wsdl:port name="TimePort" binding="tns:TimePortBinding">
<soap:address location="http://9.57.13.211/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Get z/TPF and WebSphere Application Server in a Service Oriented Architecture now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.