Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed


email article
printer friendly

Achieve J2EE-PHP Interoperability
Employ two methods of interoperability to instantiate and manipulate Java objects from within PHP scripts as if they were native PHP objects.
by Andi Gutmans, Stew Nickolas, and Zeev Suraski

November 1, 2006

PHP adoption in enterprises is increasing rapidly, and as this adoption is happening an increasing amount of projects are reusing existing J2EE investments on the back end with PHP as a front-end glue technology. Let's take a look at an interoperability scenario between the J2EE platform and PHP.

ADVERTISEMENT

Although the scenario here is generic, for the sake of this discussion we'll be using WebSphere Application Server as the J2EE back-end system and the Zend Platform for its PHP/Java Bridge, which is an efficient way of calling Java from within PHP scripts. PHP is used to implement a Web-based front end for a set of existing WebSphere assets that provide the implementation of a catalog and ordering management system. The sample application is a fictitious, supply-chain management application in which a retailer offers consumer electronic goods.

The two methods of interoperability between WebSphere and PHP are Web services and Zend Platform's PHP/Java Bridge. With Web services PHP supports creating and consuming them using its native SOAP extension. PHP's native SOAP extension takes advantage of PHP 5's new object-oriented overloading capabilities to automatically map class attributes to the datatypes defined in the WSDL file. The ability to dynamically overload the object-oriented syntax is one of PHP's key strengths and is because of its dynamic nature.

The Zend Platform's PHP/Java Bridge provides the ability for PHP developers to create applications that interact with Java objects. Using the overloading capabilities just mentioned, Java objects can be instantiated and manipulated from within PHP scripts as if they were native PHP objects.

This scenario uses the PHP/Java Bridge to access the back-end catalog and ordering systems running in the WebSphere application and acts as a single J2EE application client (see Figure 1).

Retailer Implementation
In the context of the interoperability scenario presented here, we'll discuss these topics:

  • Sample description – A detailed discussion of the sample scenario including page flow, Web services, Enterprise JavaBeans (EJB), and prerequisites for installing the technologies.
  • Setting up the PHP/Java Bridge to work with WebSphere – A detailed description of the J2EE assets used including setting up and testing the PHP/Java Bridge with WebSphere and tips and techniques for developing and debugging.
  • Web services – In the sample application, Web services are used as the communication channel between the retailer client and server. PHP's dynamic nature is ideal for implementing Web services layers, and both the client and server parts are implemented in PHP. PHP 5 allows for very elegant separation between PHP's object-oriented syntax and semantics.
  • Using the PHP/Java Bridge to interoperate in the example – The PHP/Java Bridge module provides PHP-centric companies with a well-rounded environment that ensures that the organization benefits from the "best of both worlds," be it existing investments in J2EE application servers that require this solution, to provide a means for organizations if they choose, or to complement the PHP environment with Java. The PHP/Java Bridge is not limited to interactions strictly with J2EE and legacy systems; it also provides the ability to interact with plain Java objects.

The fictitious, supply-chain management application consists of a retailer that offers electronic goods to consumers. A Retailer component is implemented using a Web service that is based on the WS-I.org base profile sample application. It provides methods for listing the contents of the retailer’s catalog and placing an order for a collection of goods. To fulfill orders the Retailer component makes a request to a Warehouse client to ship the items. In this example, only one Warehouse is used to restock an item. The Retailer will call the Warehouse requesting the item for shipment. Each Warehouse maintains stock levels for each item. The high-level architecture of the sample application is shown in Figure 2.




Back to top












Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTPOnline Home