Accessing Adabas using the PHP SOAP extension

This tutorial

  • Demonstrates how to access SOA Gateway from a PHP script

  • Provides a number of PHP examples.


What is PHP ?

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

The PHP interpreter is available as source code or as pre-compiled binaries for major platforms, including most Linux™ distributions, Windows®, Mac OS X, and iSeries™.

The latest release is PHP 5 and is seeing increasing adoption. PHP 5 introduces improvements to the object model; also, the underlying memory management has been redesigned with multi-threading and performance in mind.

For more information about PHP, or to download the software, please refer to the PHP homepage.

New in PHP 5 is a built-in SOAP extension. It is supplied as part of PHP.

For this tutorial to work, you should have PHP 5 up and running in your Web server, see the install.txt document in the PHP distribution library for details.

Installing the Eclipse PHP Development Tools

The Eclipse PHP Development Tools (PDT) are not absolutely necessary, but using Eclipse greatly simplifies the development process. This tutorial assumes the PDT to be installed.

Please refer to the Eclipse PDT project pages for installation and configuration instructions.

Accessing Adabas from PHP

  1. First, create a new project within your workspace.

    graphics/php01.jpg

  2. Opt to create a PHP Project, click Next

    graphics/php02.png

    Give the project a name and unselect the "Use default" box. Browse to the default location of your html documents, in this case an Apache server document folder called "ASGdocs", click Finish

    graphics/php03.png

    If you are asked to switch to the PHP perspective, opt to do so

    graphics/php03a.png

  3. Create the PHP SOAP client

    Create a PHP script file by right-clicking into the Eclipse Navigator area, select New -> PHP File

    graphics/php04.jpg

    Specify a File name, click Finish

    graphics/php05.jpg

    Opt to create a "Simple PHP File"

    graphics/php05x.png

    The PHP SOAP class to represent the Adabas Service is called SoapClient, the first step will be to instantiate SoapClient, passing the URL of an SOA Gateway WSDL as the parameter:

    graphics/php05a.jpg

    Now that we have instantiated our client we want to see what methods it provides and what parameters are required. Fortunately we can get PHP and the instantiated SoapClient class to do most of the work for us easily:

    graphics/php05b.jpg

    If you run this as a console application (via "Run") the output is much better formatted than running it in the PHP browser. The console window will show the following:

    graphics/php05c.jpg

    This shows that the service described by the WSDL provides five operations: list, get, delete, add and update; It also lists the required parameters and the responses given.

    A description of the input and output parameters can be retrieve by calling the __getTypes class:

    graphics/php05d.jpg

    The output will look like this:

    graphics/php05e.jpg

    This information is sufficient to construct the first simple call to the "list" operation.

    First an array of the required input parameters needs to be constructed:

    graphics/php05f.jpg

    Ready to invoke the "list" operation as a method of the soapclient class:

    graphics/php05g.jpg

    Now it is just a matter of taking the returned object and outputting the required results in a table:

    graphics/php05h.jpg

    Run this in the built in PHP Browser (activated with "Window" -> "Show view" and select "PHP Browser") or an external browser: http://<your_localhost_url>/PHPempMini.php:

    graphics/php05i.jpg

PHP Examples

The following PHP examples can be copied from here, moved to your web server's DocumentRoot (for example) and executed: