Version 3.0 - September, 2006
Direct Java BPEL Process Invocation
Introduction
Dependencies
Deploying the Web Application
Running the JSP Client

Direct Java BPEL Process Invocation

Introduction

This sample shows how to invoke a BPEL process directly from Java code. It includes a client JSP page, the Java class that it uses, an Ant script to build and deploy a WAR file, and sample data that can be used to call the complex_exchange sample (available separately).

When calling a BPEL process directly, the Java code that does the calling must run within the same JVM as the engine.

The Source Code

Invoking a BPEL process directly involves creating the contents of the input message as one or more XML documents and placing them in the engine's received message queue.

IAeWebServiceResponse response =
AeMessageQueue.getInstance().queueReceiveData(context, messageParts);

The first argument, context, is an AeMessageContext object. All it needs is the BPEL process' service name.

AeMessageContext context = new AeMessageContext();
context.setServiceName(serviceName);

The second argument to queueReceiveData is an array of Document objects, one for each part in the WSDL input message. See the method ProcessCaller.createDocumentArray for the code that does that.

queueReceiveData returns an IAeWebServiceResponse, which contains among other things the return data as a Map that has message part names as keys and values that are Documents. ProcessCaller.responseToXmlString shows one way to turn the response into an XML string for display. That is the string displayed by the JSP page.

Dependencies

Deploying the Web Application

From the command line, navigate to the directory where you installed this sample. Then run the following command.

ant deploy

This creates and deploys the .war file containing the JSP page and ProcessCaller class.

Running the JSP Client

To use the JSP, run Tomcat and use a Web browser to visit the URL http://localhost:8080/java_process_call/index.jsp . If your Tomcat installation is not running at localhost:8080, modify the URL accordingly.

Using the BPEL Process JSP Client Page

Follow the directions on the JSP page by entering the service name in the first field and the XML in the second. Each part in the WSDL input message must correspond to a top-level element in the XML text.

To run the client against the complex_exchange sample, use the service name complexToBpelPartnerLinkService and use the contents of the file support/complex_exchange.xml as the message content.