Home >Backend Development >PHP Tutorial >Using Web Services to Access J2EE Applications in PHP5 (1)_PHP Tutorial
Many web developers like PHP's rich functionality and ease of use, but sometimes they need to access business logic already in a J2EE application server. This article will provide some examples of how to use Web services to access J2EE applications through the new SOAP extension in PHP 5, without having to leave the PHP environment or learn a new programming model.
Introduction to PHP, Web Services, and SOAP
This article explains how to access enterprise applications from PHP scripts. You might be a PHP programmer who needs to write code for a departmental web application that provides access to services provided as web services from corporate headquarters. Perhaps you are an experienced J2EE developer who would like to learn more about PHP and its applications. The example in this article is an Enterprise JavaBean (EJB) running on an IBM WebSphere® application server, but this article does not discuss the deployment of Web services. Its main goal is to introduce how to use web services from PHP, which can be applied to various web service implementations.
What is PHP?
PHP: Hypertext Preprocessor (PHP) is a popular server-side scripting language used to create dynamic web content. The PHP interpreter provides source code or compiled binaries for major platforms, including most Linux® versions, Windows®, Mac OS X, and iSeries®.
There are literally millions of web servers running PHP, and most of them use PHP 4. PHP 5, launched in July 2004, is gradually being adopted. PHP 5 has improved the object model, and the underlying memory management has been redesigned from the perspective of multi-threading and performance. However, be aware of a few modifications that are not backwards compatible, and these are documented in the PHP manual.
What is Web service technology?
Web services refer to self-contained, modular applications in which clients and services are loosely coupled. Regarding the details of web services, for the purpose of this article, you only need to know the main technologies:
SOAP (Simple Object Access Protocol) defines the messages passed between the client and the server. Messages are in XML format. SOAP is platform, programming language, network and transport layer independent. This article discusses SOAP over HTTP.
WSDL (Web Services Description Language) is an XML-based language used to describe Web services. The description includes the location, format, operations, parameters and data types of the service.
UDDI (Unified Description, Discovery, and Integration) uses APIs and UDDI Registry implementations to provide a method for storing and retrieving Web service information over the network.
This article includes some examples of SOAP messages and WSDL documents, but does not provide examples of UDDI.
The XMethods website is a useful web services tool where you can find a list of publicly available web services implemented on various server platforms. You can use the examples in this article to easily access services selected from XMethods.