242 Building SOA-based Solutions for IBM System i Platform
11.1 Consuming a Web service with PHP
This section explains how to consume the following Web services:
The first Web service,
Repeater, is a PHP Web service with two functions. It takes in a
string and an integer. The function repeat repeats a string of text a number of times and
the function reverseRepeat reverses a string of text and repeats it a number of times (see
Example 8-8 on page 182).
The second Web service,
ProgramCall, uses a PHP Web service with one function. It
takes first name, last name, and an initial amount as input. The Web Service wrappers an
i5_program_call to the INCRAMT CL program that sets the account name to the last name,
increments the balance by specified amount, and returns the results (see Example 8-11
on page 188).
The third Web service
GETFLIGHTINFOServices is a WebSphere Web service that
wrappers FLGHT400M/NSF404(FINDFLIGHTS). It takes the departure and destination
cities and the date of the flight as input. It returns the number of available flights and
available flight information.
11.1.1 Using Zend Studio for i5/OS to create Web services clients
Zend Studio for i5/OS can simplify the task of writing PHP Web services clients. For the
examples in this chapter, we use the PHP SOAP extension to create the Web services client.
To create the SOAP Client, you need the WSDL file. It can reside on a system where you run
a PHP client, you can specify it as a URL.
After you create the SOAP client, two useful features become available in Zend Studio for
i5/OS. The first is the
Inspectors view of available SOAP clients. The new SOAP Client is
visible in the File and Project Inspector view. With this view, you can expand the SOAP client
to reveal the name of the WSDL, the class it extends, the available functions, what they take
for input, and what they return for output. The second feature that is available in Zend Studio
for i5/OS after you create the SOAP client is the code completion feature. It analyzes
dynamically the WSDL file that is associated with the SOAP client and displays information
that is relevant to the function as you type.