Skip Headers
Oracle® BPEL Process Manager Developer's Guide
10g (

Part Number B28981-03
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

11 Invoking a BPEL Process

This chapter shows how a Java or JSP application can call a BPEL process to perform functions or use services.

This chapter contains the following topics:

11.1 Use Case for Invoking a BPEL Process

In this use case, you learn how to invoke synchronous and asynchronous BPEL processes through either the simple object access protocol (SOAP) or Java. The BPEL process accepts a social security number and sends a credit rating in return. The user Web interface is provided by a JSP file, which takes the input and passes it to a BPEL process to get back a credit rating.

See Also:

The following sample file:
  • SOA_Oracle_Home\bpel\samples\tutorials\102.InvokingProcesses

11.2 Overview of Invoking BPEL Process Concepts

A Java or a JSP application can call a BPEL process to perform functions or use services. A BPEL process is itself a Web service, defining and supporting a client interface through WSDL and SOAP. However, you can make BPEL processes deployed on Oracle BPEL Process Manager available to clients through a Java API.

See Also:

The tutorial at

11.3 Sending Messages to a BPEL Process from a Java or JSP Application

You can invoke a BPEL process as a Web service through a WSDL or SOAP interface, or as a Java component through its client Java interface. The application puts the request in the form of a payload that then goes to the BPEL process. The BPEL process receives the payload and responds with a payload containing the information that the application requested.

shows how an application interacts with a BPEL process through a client partner link, using one of a number of possible protocols.

Figure 11-1 Application Interaction with a BPEL Process

Description of bpmdg004.gif follows
Description of the illustration bpmdg004.gif

11.3.1 Invoking a BPEL Process with the Generic Java API

You can invoke a BPEL process by using a generic Java API. Oracle provides classes that enable your BPEL process to use a generic Java API to connect to Oracle BPEL Process Manager and to pass XML messages through a generic Java API. You can use these classes to perform either two-way or one-way invoke operations.

This section covers the following topics: Connecting to Oracle BPEL Process Manager with the Locator Class

Oracle provides a class that supports a flexible client interface without being affected by server clustering and other production details. Use this class to do the following:

  • Connect to Oracle BPEL Process Manager, authenticating if required

  • Obtain handles to services provided by Oracle BPEL Server

For example, the Locator class can connect to the default domain on a local Oracle BPEL Process Manager and fetch a list of BPEL processes deployed on that server. In this case, the Locator class returns a handle to a instance.

The following instance can invoke or initiate BPEL processes on Oracle BPEL Server:


// Connect to domain "default" using password ÒbpelÓ
// null IP address means local server

Locator locator = new Locator("default", "welcome1", null);

IDeliveryService deliveryService = (IDeliveryService)locator.lookupService
     (IDeliveryService.SERVICE_NAME );


This instance code example uses welcome1 as the domain password. Update the instance with the correct password for your environment. Passing XML Messages Through Java

Because all Web services, including BPEL processes, accept and return XML messages, any Java API using Web services needs a way to pass XML data through Java. You can use the Oracle BPEL Process Manager client class to activate an XML message dynamically.

For example, to activate an input message for the CreditRatingService from static string XML data, you can use the following code:

String xml =
"<ssn xmlns=\"\">123456789</ssn>";

NormalizedMessage nm = new NormalizedMessage( );
nm.addPart("payload", xml );

In practice, you activate NormalizedMessages more dynamically. For full documentation of the NormalizedMessage class, see the Oracle BPEL Process Manager Javadocs in:

  • SOA_Oracle_Home\bpel\docs\apidocs Invoking a Two-Way Operation Through the Java API

After a delivery service has been instantiated, it can initiate a BPEL process with a NormalizedMessage XML message. You can use one of the IDeliveryService.request() methods to invoke a two-way Web service operation, which has an input message and returns a result synchronously.

The IDeliveryService.request() method is overloaded. To find out more about its available versions, refer to the Oracle BPEL Process Manager Javadoc. In this version, the request() method has the following signature:

public NormalizedMessage request(java.lang.String processId,
                                 java.lang.String operationName,
                                 NormalizedMessage message)
                          throws java.rmi.RemoteException

The following code example (provided with the Oracle BPEL Process Manager samples) demonstrates how to use this API to invoke the CreditRatingService BPEL process.

<%@page import="java.util.Map" %>

<%@page import="" %>
<%@page import="" %>
<%@page import="" %>
<title>Invoke CreditRatingService</title>
String ssn = request.getParameter("ssn");
if(ssn == null)
ssn = "123-12-1234";
String xml = "<ssn xmlns=\"\">"
+ ssn + "</ssn>";
Locator locator = new Locator("default","bpel",null);
IDeliveryService deliveryService =
(IDeliveryService.SERVICE_NAME );
// construct the normalized message and send to oracle bpel process
NormalizedMessage nm = new NormalizedMessage( );
nm.addPart("payload", xml );
NormalizedMessage res =
deliveryService.request("CreditRatingService", "process", nm);
Map payload = res.getPayload();
out.println( "BPELProcess CreditRatingService executed!<br>" );
out.println( "Credit Rating is " + payload.get("payload") );

See Also:

The following sample:
  • SOA_Oracle_Home\bpel\samples\tutorials\102.InvokingProcesses\jsp\invokeCreditRatingService.jsp Invoking a One-Way Operation Through the Java API

A one-way invoke operation has only an input message and does not return a result. The procedure for invoking a one-way BPEL operation through the Java API is very similar to how you invoke two-way operations. The difference is that you use the method instead of IDeliveryService.request(). This method is overloaded; its methods invoke a one-way operation on a BPEL process and thus return void because a response is not expected (at least not a synchronous response).

From the Javadoc for

public void post(java.lang.String processId,
                 java.lang.String operationName,
                 NormalizedMessage message)
          throws java.rmi.RemoteException

In the following example, the post() method is very similar to the request() method shown in the two-way example discussed earlier, except that it returns void.

<%@page import="" %>
<%@page import="" %>
<%@page import="" %>
Locator locator = new Locator("default", "bpel", null);
NormalizedMessage nm = new NormalizedMessage( );
nm.addPart("payload" , xml );"HelloWorld", "initiate", nm);
out.println( "BPELProcess HelloWorld initiated!" );

See Also:

The following sample:
  • SOA_Oracle_Home\bpel\samples\tutorials\102.InvokingProcesses\jsp\invokeHelloWorld.jsp

11.3.2 Retrieving Status or Results from Asynchronous BPEL Processes

If you use the Java API to initiate an asynchronous BPEL process, you must often consider how to receive the result of the process, because a typical Java client cannot be called back the same way as a Web service. You can handle this problem by using the following strategies:

  • Have your code inform users of the progress of the process. For example, the LoanFlowPlus BPEL demonstration application (located in SOA_Oracle_Home\bpel\samples\demos\LoanDemoPlus) informs users of the progress through a user task, such as manually approving the final loan offer. You also can have the process send some sort of notification, such as an e-mail message or a JMS message, when it completes.

  • For asynchronous BPEL processes, have the Java client poll the result. In this case, the client needs a handle to fetch status information for a particular instance. The post() method does not automatically return such a handle, but it does allow the client to specify a conversation ID. This ID can be any unique identifier that the client can later use to identify a specific instance and retrieve status information for it. See the Oracle BPEL Javadocs for the class to find the specific field name for the conversation ID and other properties, which you can set at the time a BPEL process is instantiated through the Java API. You can also use the key) method to locate a specific instance based on a conversation ID.

    You also can use the NormalizedMessage properties to specify the address of a Web service for the callback. This initiates an asynchronous BPEL process from Java, but receives a SOAP/XML callback to a Web service listener.

It is also possible using the supported NormalizedMessage properties to specify the address of a Web service for the callback and therefore initiate an asynchronous BPEL process from Java, but receive a SOAP/XML callback to a Web service listener.Contact Oracle Support Services for more information on how to retrieve status or results from an asynchronous BPEL process in your specific environment.

11.3.3 Using the Java API from a Remote Client

The code examples described in previous sections are executed within the same application server container in which the Oracle BPEL Process Manager is running. You can run these APIs from a remote client, however, and use them through a remote method invocation (RMI) from a remote application server. The RMI client code you use depends on the application server in which the client is running. Work with Oracle Support Services regarding how to use the Oracle BPEL Process Manager Java API over RMI for your specific client configuration and environment.

11.3.4 Invoking a BPEL Process with the Web Service/SOAP Interface

After you deploy a BPEL process to Oracle BPEL Server, it is automatically published as a Web service. This means that the process can be accessed through its XML/SOAP/WSDL interface without any additional developer effort. Supporting a standard Web services interface means that BPEL processes can be invoked from any client technology that supports Web services. This includes Microsoft .NET, Sun's JAX-RPC implementation, Apache Axis, Oracle JDeveloper, and many other Web services tool kits. In addition, it means that BPEL and Oracle BPEL Process Manager can publish Web services. Those services, both synchronous and asynchronous, can be invoked from applications and services implemented with nearly any technology and language.

You access a BPEL process through its Web service interface in the standard way you access any Web service: by writing a client that uses the BPEL process WSDL interface definition and SOAP as a protocol.

11.4 Summary

Once deployed, a BPEL process is exposed through both a WSDL or SOAP interface and a business delegate Java interface. The Java business delegate interface allows Java and JSP applications to initiate new instances of a BPEL process.The Java business delegate can be used locally or remotely using RMI. The Java business delegate is JTA-aware, allowing the initiation of a process to be part of a broader transaction.