SourceForge.net Logo

InstantSVC

Overview

Web Services are one of the key elements in modern software architectures, e.g. the Service-oriented Architecture. It is more than only a buzzword, becaue it is actually useful.

PHP is a dynamic, object oriented programming language that has proven to serve well for writing web applications. It is suitable for creating Web Services as well. With PHP5, a build-in extension has enriched the possibilities to provide high-performance and reliable services supporting the SOAP protocol. But at this point the support for tool based software development ends without useful features like support for enhanced Web Services Standards or generation of Web Services descriptions using WSDL.

Ok, at this point one could argue that SOAP is not suitable for all applications and REST could serve this much better, but for both technologies tool support is essential for developing large applications. So what is missing for REST and SOAP Web Services in a standard PHP development environment?

Our vision was to have a tool based solution for adding Web Service APIs to an existing application core without necessarily implementing this APIs on top of the application just to compensate environment specific issues.

Most non-design related issues can be solved easily with tool support. The WSDL descriptions necessary for professional SOAP Web Services can be generated from the interface already defined by the application classes. Support for advanced WS-* Standards could be added by configuration using a set of libraries. For REST Services the design approach is different, but tool based support to map the service to an object-oriented application core can be provided, too. The main issues here are data formats and URL-to-API mapping which can be solved with a REST Server. This server works with configuration rules describing the (de)serializer to be used on a specific request and the API method to be called in the application core.

To fulfil these needs the following features are provided.

Features

  • Extended Reflection API
    • adds type information to PHP via PHPDoc comments
    • adds annotations to PHP
  • WS-I conform WSDL-Generator
    • generates WSDL from your PHP files
  • document/literal-Adapter-Generator
  • Handler-Chain-Mechanism for SOAP processing
    • useful to provide WS-* support
    • implementation of WS-Security and Username Token Profile
  • rich support for REST Web Services
    • rule based request to API mapping
  • Administration Tool for comfortable creation und management of SOAP- and REST-Services

Usage

One of the main scenarios to use this toolkit is to add Web Services to existing web applications. How this is implemented is shown in Fig. 1.

InstantSVC Usage Scenario - FMC Diagram
Fig. 1.   Usage Scenario for InstantSVC – FMC Block Diagram

A given application core could be enhanced by Web Services APIs with the InstantSVC tools. The application core is shrewdly implemented with object oriented PHP, but not necessarily. A clean documented procedural style PHP application is fine, too. This application is build by application developers and can be enhanced ideally without the need of additional Web Service programming skills. A so called Web Services Administrator can use this toolkit to add Web Services to the application while only knowing the delivered application documentation. Well, this is a very ideal situation. Nevertheless, it is intended to be able to use this toolkit without having the need to change or add new code to an application.

At the moment a web based user interface and commandline tools are available as administration tools. These tools are working with the five main components ClassLoader, WSDL Generator, Adapter Generator, SOAP Server Generator and REST Server Generator, which are based on the Extended Reflection API.

The ClassLoader is not a Class Loader like it is known from Java or something similar. It is used to gather information from a source tree and ensures that the current PHP process does not terminate through including broken files or duplicate functions/classes.

WSDL files are generated by the WSDL Generator using selected class definitions or a list of functions. At this point a PolicyPlugin can be used to enable the Web Services Administrator to select classes or functions from an unprepared application core for publishing them as Web Services. This plugin got a web frontend to fulfil these task. It is possible to change or add a documentation to the generated WSDL files based on rules for hiding internal details or providing additional information defined in the PolicyPlugin.

For SOAP document/literal-wrapped Web Services additional adapter classes are necessary to act on the application core. The PHP code for this classes is generated by the Adapter Generator.

To provide Web Services with a minimal effort, configurable server scripts are also given. The SOAP Server Generator and REST Server Generator will create the configuration files and deploy them together with the server scripts to a given directory. From there the servers can be accessed by remote clients and answer SOAP- or REST-style Web Service requests. The server configuration files are plain PHP files returning an array with config-values. It is not intended to use a XML or plain text configuration for performance reasons. It would be possible to add a config generator not just using source files documentation as input to generate server configurations, but also XML configuration files.

The provided tools make use of this components starting at first gathering information about the application or just working on a given source file. So it is possible to select web services via a user interface or via annotations in the source code documentation. Afterwards, if a SOAP service is to be build, the WSDL generator uses the Extended Reflection API to inspect all classes/functions and there used data types to build a WSDL file. For wrapped style services adapter classes are generated, too. In the last step the configuration settings are detected or requested from the user to build a config file and deploy the REST/SOAP server scripts.