Integrating PHP Web Services using Oracle BPEL
Alison Holloway, Product Manager, Oracle Corporation
In November 2005 I attended the PHP Conference in Frankfurt. At that conference
I did a demonstration which showed how to integrate PHP Web Services using Oracle
BPEL, and the Oracle JDeveloper PHP Extension. I have written up that demo for
others to get an overview of what I talked about and showed to the conference
If you have PHP web services you want to integrate into a new web service,
or business process, then BPEL is your answer. BPEL lets you orchestrate your
disparate web services into new web services. You can even use the BPEL web
services as part of another BEPL web service. The beauty of web services is
that they can be in a variety of languages, so you can reuse your PHP web services
and ones in other languages.
This article gives an overview of the tools you could use to create BPEL processes:
- Oracle JDeveloper 10g PHP Extension – an extension to Oracle JDeveloper
10g to create and edit PHP scripts, with syntax highlighting and
sample code to create connections to an Oracle database.
- Oracle BPEL Designer – an extension to Oracle JDeveloper 10g to
graphically create and orchestrate BPEL processes.
- Oracle BPEL Console – a web service to start, stop, monitor and debug BPEL
- Oracle BPEL Worklist – a web service to interract with BPEL processes that
require user intervention.
These tools help you to quickly get started creating BPEL processes to incorporate
your PHP web services into new business processes.
Let’s suppose you have a departmental application to approve employee leave
requests. A PHP developer has written this application as a web service and
managers log into the application to manage the leave requests. The employee
leave request table contains a row with the identifier of 1004, which is a leave
request for an employee, CJONES. You can see this leave request in the PHP web
service used by department managers to approve employee leave requests.
Figure 1, PHP Web Service Consumer Interface
This is a standalone application that you now want to incorporate into a new
company-wide business process as a web service. You can use BPEL to do this.
Let’s now run through the Oracle BPEL and PHP tools.
Oracle JDeveloper 10g PHP Extension
This PHP web service was written using the Oracle JDeveloper 10g PHP
Extension. This extension was written by Oracle and gives you, amongst other
things, PHP code syntax highlighting, and some snippets of code that help you
get started creating connections to an Oracle Database. Here’s a look at the
PHP Extension in action.
Figure 2, Oracle JDeveloper 10g PHP Extension
The code snippets shown in the Component Palette are included in the PHP Extension
and enable to to quickly create database connections and run SQL statements.
The Structure pane includes a list of PHP functions and their respective variables.
Although the PHP Extension doesn’t give you PHP debugging, it may be useful
if you want to write or edit PHP files while creating a BPEL application.
To create a BPEL process which will incorporate this PHP web service, you would
use the Oracle BPEL Designer.
Oracle BPEL Designer
The Oracle BPEL Designer is another extension to Oracle JDeveloper 10g.
I would suggest installing the Oracle BPEL Designer (Oracle JDeveloper 10g
and the BPEL Designer Extension) first, and then add the PHP Extension. There
is also an Oracle BPEL Designer extension available for Eclipse, although this
doesn’t include the Oracle-specific features.
Here’s a look at the BPEL Designer interface.
Figure 3, Oracle BPEL Designer Interface
The BPEL Designer gives you a graphical tool to create and orchestrate BPEL
processes. For example, you can click and drag in PartnerLinks (links to WSDL
files for web services), User Tasks (interraction by a user), add decision making
elements such as While loops, Waits, Switches, and throw errors.
The BPEL process shown here includes a Partner Link to a database adapter,
called DBRead in Figure 3. This enables you to make direct calls to an Oracle
Database to query and update data. This BPEL process queries the database using
the leave request ID and returns the row associated with that ID. The BPEL process
then manipulates the results using XSLT and XQuery functions to format the query
results, and create new variables required by the process.
There is also some decision making in the process. In this case, there is a
switch statement which enables different actions to be performed depending on
whether the leave request is approved, denied, or an error is generated.
If the employee leave request is approved, the BPEL process will use the PHP
web service, called PHPUpdateDB in Figure 3, to delete the row from the departmental
table. The BPEL process can then update the main human resources database with
the employee leave request information using another web service, or a direct
database update using a database adapter.
When the BPEL process is ready to deploy, the BPEL Designer will generate all
the required deployment information and deploy it to the BPEL Process Manager
BPEL Process Manager
The BPEL Process Manager is a J2EE application which allows you to start, stop,
monitor, debug, and kill BPEL processes. You can monitor the state of all the
BPEL processes and drill down to individual SOAP messages. This is useful for
debugging processes while you’re developing them, as well as monitoring them
when they have been deployed.
The BPEL Process Manager can be deployed to a standalone OC4J instance (which
is the default deployment option and included in the BPEL Process Manager),
or to another J2EE compliant server.
When the BPEL process is deployed, use the BPEL Work Console to start and stop,
monitor, and debug BPEL processes.
BPEL Work Console
The BPEL Work Console is used to start, monitor and debug BPEL processes. The
BPEL Work Console is a web service and sends a SOAP message to the BPEL process.
Using the LeaveRequestID of 1004 and sending the process an XML message will
start the process.
Figure 4, Starting a BPEL process using the Oracle BPEL Console Interface
The BPEL process verifies that the LeaveRequestID exists by using a Database
PartnerLink (web service) to select a row from the table and retrieve the contents
of that row. This is a direct database query and does not use the PHP web service.
When the BPEL process is started, the BPEL Console displays a screen with options
to visually track the flow, audit it using XML, or to debug it.
Figure 5, BPEL process monitoring options using the Oracle BPEL Console
The Visual Flow is a very easy way to see what state the process is in, what
variables have been passed, what decisions have been made, and what errors may
have been generated. In this case, the BPEL process has halted and is waiting
for manual intervention at the receiveUpdate… User Task.
Figure 6, BPEL process waiting for user input using the Oracle BPEL Console
You could write an application yourself which would allow you to interract
with the BPEL process (web service), or you can use the Oracle BPEL Worklist.
The BPEL Worklist is a supplied web service which enables you to interract with
BPEL processes that require user intervention.
The BPEL Worklist shows a list of the User Tasks assigned to a manager. In
this case, it is the approval of the employee leave request.
Figure 7, Acquiring a task using the BPEL Worklist Interface
The task must be acquired by the manager before any action or decision can
be made on it. Once the task is acquired, the manager can approve, reject or
escalate the task to a supervisor.
The escalation heirarchy is managed by JAZN (Oracle’s implementation of Java
Authentication and Authorization Service (JAAS)) and can be either set up using
the JAZN interface, or connected to an LDAP or SSO Server.
Figure 8, Approving a task using the BPEL Worklist Interface
When the task is approved, the BEPL process receives a message from the Worklist
web service and continues processing. The BPEL process continues through its
decision making and processing, assigning variables to whatever is required
using simple transformations, or XSLT.
Figure 9, BPEL process execution completed using the Oracle BPEL Console
You can click on any of the events in the process to see the SOAP messages
being generated For example, the result of invoking the GetLeaveDetails Partner
Link generates the following SOAP message.
Figure 10, DBRead Database Adapter SOAP messages displayed using the Oracle
BPEL Console Interface
The SOAP message displays the input and output variables of the message. You
can see that the input variable is lrequest=1004, and the output variables are
employeeId=CJONES, id=1004, leaveTypeId=7 and noOfDays=4. This message represents
a request to the database Partner Link to retrieve the row with the leave request
identifier of 1004.
Now that the BPEL process has finished, and the database updated to remove
the leave request with an ID of 1004, logging into the PHP web service shows
that the database has been updated. The leave request with an ID of 1004 is
no longer displayed.
Figure 10, PHP Web Service Interface showing ID 1004 removed from the database
This is a very simple BPEL process and PHP web service, but it shows that you
can use BPEL to integrate existing PHP web services with other web services
to create new business processes.
For further information on BPEL and using PHP with Oracle, go to the following
Oracle BPEL Process Manager
Service-Oriented Architecture Technology Center
PHP Developer Center
Zend Core for Oracle
Oracle JDeveloper 10g PHP Extension