Legal | Privacy
Initiating a BPEL Business Process using a Java UI

Initiating a BPEL Business Process using a Java UI

This tutorial covers how to initiate a BPEL business process using a JavaServer Pages (JSP) Web-based user interface (UI).

Approximately 1 hour

Topics

This tutorial covers the following topics:

Creating the JavaServer Pages User Interface

Initiating MyLoanFlow BPEL using the Java API

Testing the Java UI that Initiates MyLoanFlow

Place the cursor over this icon to load and view all the screenshots for this tutorial. (Caution: Because this action loads all screenshots simultaneously, response time may be slow depending on your Internet connection.)

Note: Alternatively, you can place the cursor over each individual icon in the following steps to load and view only the screenshot associated with that step.

Overview

In this tutorial you create a file called invokeMyLoanFlow.jsp that contains HTML and JSP tags to form a user interface, which submits loan application data and initiates the MyLoanFlow BPEL process. The tutorial provides the steps required to build the JSP logic.

Your JSP application is deployed along with other a JSP application files in the D:\orabpel\samples\tutorials\102.InvokingProcesses directory tree of your Oracle BPEL Process Manager installation. This application tree supplies the appropriate configuration files needed for the Web application to locate the Java API code referenced by your JSP file.

After the MyLoanFlow BPEL instance has been intiated by the JSP application, you view the BPEL process using the Visual Flow view of the Oracle BPEL Console. You use the StarLoanUI to complete the manual processing of the StarLoan service's loan offer.

Back to Topic List

The JSP application used to initiate the MyLoanFlow BPEL process provides a HTML form user interface to submit a loan application:

You enter data in the HTML form fields and click Send Application to submit the data and to initiate the MyLoanFlow BPEL process to manage the loan application. The same JSP page is used to receive the HTML form fields and construct the loan application XML document. The loan application document is supplied as input to the MyLoanFlow BPEL process that is initiated by using the appropriate Java API calls needed to start the BPEL process.

The JSP application logic is represented by the following flow diagram:

Having invoked the MyLoanFlow BPEL process, you use Oracle BPEL Console to monitor progress, and use the StarLoanUI to accept the loan application.

Back to Topic List

Prerequisites

Before starting this tutorial, you should:

1.

Install Oracle BPEL Designer and Oracle BPEL Process Manager server, as discussed in the OBE tutorial called "Installing Oracle BPEL Designer and Oracle BPEL Process Manager."

 

2.

Start Oracle BPEL PM Server.

.

3.

Complete the OBE tutorial called "Invoking Asynchronous Business Services using BPEL."

Note: If you have not completed the "Invoking Asynchronous Business Services using BPEL" tutorial then perform the following tasks:

Download the tutorial solution project.

Unzip the solution files into the <drive>:\eclipse\workspace directory.
Note: This action may overwrite files in the <drive>:\eclipse\workspace\MyLoanFlow directory.
Open the MyLoanFlow project in Oracle BPEL Designer.
Deploy the CreditRatingService as documented in the "Invoking a Synchronous Business Service using BPEL" tutorial. This service can deployed from the <drive>:\orabpel\samples\utils\CreditRatingService directory in the Oracle BPEL Process Manager installation.
Deploy the UnitedLoan and StarLoan loan services as documented in the "Invoking Asynchronous Business Services using BPEL" tutorial. The services can be deployed from the <drive>:\orabpel\samples\utils\AsyncLoanService directory in the Oracle BPEL Process Manager installation.

Back to Topic List

Creating the JavaServer Pages User Interface

To construct the JSP file with an HTML form to submit the loan application, perform the following steps:

1.

To create a text file called invokeMyLoanFlow.jsp in the D:\orabpel\samples\tutorials\102.InvokingProcesses\jsp directory, use your preferred text editor, start a command window and enter:

cd D:\orabpel\samples\tutorials\102.InvokingProcesses\jsp
notepad invokeMyLoanFlow.jsp

Place the cursor over this icon to see the image

Note: This tutorial uses Notepad as the text editor, and has Oracle BPEL Process Manager files installed on the D: drive.

 

2.

To create basic structure of the JSP application represented by the flow diagram above, in the text editor enter the following JSP declarations, HTML tags, and JSP scriptlets:

<%@page import="com.oracle.bpel.client.Locator" %>
<%@page import="com.oracle.bpel.client.NormalizedMessage" %>
<%@page import="com.oracle.bpel.client.dispatch.IDeliveryService" %>
<html>
  <head>
   <title>Invoke MyLoanFLow</title>
  </head>
<body>
<%
  String ssn = request.getParameter("SSN");
  if (ssn == null)
  {
%>
    <!-- Construct HTML form here -->
<%
  }
  else
  {
    // 1. Get form fields
    // 2. Create loan application XML document
    // 3. Initiate the BPEL process here
  }
%>
<body>
</html>

Place the cursor over this icon to see the image

Note: The skeleton JSP application code:

Includes JSP page directives, in the first three lines, to enable successful compilation and execution of the Java API calls that will be added in the else statement block to invoke the MyLoanFlow BPEL process.

Assigns the SSN form parameter value to a Java String variable called ssn.

Uses an if statement to test if the ssn variable is equal to the null reference, that is, the loan application data was not submitted.

Provides a HTML comment placeholder for the HTML form tags to be added inside the if statement code block.

Provides an else block to:

  1. Get the form data values
  2. Create a loan application XML document
  3. Initiating the MyLoanFlow BPEL process, supplying the loan application XML document as input.

 

3.

To present the HTML form interface, add the following HTML tags (in bold) inside the if statement block immediately below the HTML comment "<!-- Construct HTML form here -->" :

 <!-- Construct HTML form here -->
 <h3>Invoke MyLoanFlow BPEL Application</h3>
 <h4>Loan Application Form</h4>
 <form>
   <table>
   <tr>
     <td>SSN:</td>
     <td><input type="text" name="SSN" value="123456789"></td>
   </tr>
   <tr>
     <td>Email:</td>
     <td><input type="text" name="email" value="demo1@otn.com"></td>
   </tr>
   <tr>
     <td>Customer Name:</td>
     <td><input type="text" name="name"></td>
   </tr>
   <tr>
     <td>Loan Amount:</td>
     <td><input type="text" name="amount" value="1000"></td>
   </tr>
   <tr>
     <td>Car Model:</td>
     <td><input type="text" name="model" value="Buick"></td>
   </tr>
   <tr>
     <td>Car Year: </td>
     <td><input type="text" name="year" value="2004"></td>
   </tr>
   </table>
   <input type="submit" value="Send Application">
 </form>

Place the cursor over this icon to see the image

Note: The <form> tag does not specify any action attribute. Therefore, when the form data is submitted, the default action causes the form data to be sent to the same JSP application page generating the form. The Java code to handle the submitted data is added to the else code block in subsequent steps.

 

Back to Topic List

Initiating MyLoanFlow BPEL using the Java API

To create the loan application XML document and initiate the MyLoanFlow application using the Oracle BPEL Java API calls, perform the following steps:

1.

In the else block immediately below the Java comment "// 1. Get form fields" of invokeMyLoanFlow.jsp, add the following Java code (in bold) to get the HTML form parameter values:

<%
  }
else
{
// 1. Get form fields
String email = request.getParameter("email");
String name = request.getParameter("name");
String amount = request.getParameter("amount");
String model = request.getParameter("model");
String year = request.getParameter("year");
// 2. Create loan application XML document
// 3. Initiate the BPEL process here } %>

Place the cursor over this icon to see the image

Note: The SSN field value has been obtained in the statement just before the if statement.

2.

To construct the loan application XML document in a Java String variable called xml, add the following Java code (in bold) after the Java comment "// 2. Create loan application XML document":

<%
  }
else
{ // 1. Get form fields
String email = request.getParameter("email");
String name = request.getParameter("name");
String amount = request.getParameter("amount");
String model = request.getParameter("model");
String year = request.getParameter("year"); // 2. Create loan application XML document
String xml = "<loanApplication xmlns=\"http://www.autoloan.com/ns/autoloan\">"
+ "<SSN>" + ssn + "</SSN>"
+ "<email>" + email + "</email>"
+ "<customerName>" + name + "</customerName>"
+ "<loanAmount>" + amount + "</loanAmount> "
+ "<carModel>" + model + "</carModel> "
+ "<carYear>" + year + "</carYear> "
+ "<creditRating /> "
+ "</loanApplication>";
// 3. Initiate the BPEL process here } %>

Place the cursor over this icon to see the image

Note: The XML document is constructed with the values obtained from the HTML form parameters.

 

3.

To initiate the MyLoanFlow BPEL process, add the following Java code (in bold) after the Java comment
"// 3. Initiate the BPEL process here":

<%
  }
else
{ // 1. Get form fields
String email = request.getParameter("email");
String name = request.getParameter("name");
String amount = request.getParameter("amount");
String model = request.getParameter("model");
String year = request.getParameter("year"); // 2. Create loan application XML document
String xml = "<loanApplication xmlns=\"http://www.autoloan.com/ns/autoloan\">"
+ "<SSN>" + ssn + "</SSN>"
+ "<email>" + email + "</email>"
+ "<customerName>" + name + "</customerName>"
+ "<loanAmount>" + amount + "</loanAmount> "
+ "<carModel>" + model + "</carModel> "
+ "<carYear>" + year + "</carYear> "
+ "<creditRating /> "
+ "</loanApplication>"; // 3. Initiate the BPEL process here // Connect to Oracle BPEL server Locator locator = new Locator("default","bpel");
IDeliveryService deliveryService = (IDeliveryService)
locator.lookupService(IDeliveryService.SERVICE_NAME );
// Construct a normalized message and send to Oracle BPEL Process Manager
NormalizedMessage nm = new NormalizedMessage();
nm.addPart("payload", xml);
// Initiate the BPEL process
deliveryService.post("MyLoanFlow", "initiate", nm);
} %>

Place the cursor over this icon to see the image

Note: The Locator class is used to connect to the BPEL server specifying the Domain of default and the password bpel (as used in the BPEL Console Web page). An IDeliveryService instance is created by using the lookupService() method of the locator object. In the last statement, the post() method of the IDeliveryService instance initiates the MyLoanFlow BPEL process. The last argment of the post() method call is a NormalizedMessage object, containing the XML document wrapped in its payload part, providing the loan document as input to the initiated BPEL process.

 

4.

At the end of the else block (before the closing brace "}") , add the following HTML and JSP code (in bold) to provide feedback indicating the that the MyLoanFlow BPEL process has been initiated with the submitted SSN value:

<%
  }
else
{ // 1. Get form fields
String email = request.getParameter("email");
String name = request.getParameter("name");
String amount = request.getParameter("amount");
String model = request.getParameter("model");
String year = request.getParameter("year"); // 2. Create loan application XML document
String xml = "<loanApplication xmlns=\"http://www.autoloan.com/ns/autoloan\">"
+ "<SSN>" + ssn + "</SSN>"
+ "<email>" + email + "</email>"
+ "<customerName>" + name + "</customerName>"
+ "<loanAmount>" + amount + "</loanAmount> "
+ "<carModel>" + model + "</carModel> "
+ "<carYear>" + year + "</carYear> "
+ "<creditRating /> "
+ "</loanApplication>"; // 3. Initiate the BPEL process here // Connect to Oracle BPEL server Locator locator = new Locator("default","bpel");
IDeliveryService deliveryService = (IDeliveryService)
locator.lookupService(IDeliveryService.SERVICE_NAME );
// Construct a normalized message and send to Oracle BPEL Process Manager
NormalizedMessage nm = new NormalizedMessage();
nm.addPart("payload", xml);
// Initiate the BPEL process
deliveryService.post("MyLoanFlow", "initiate", nm); %>
<p>BPEL Process <code>MyLoanFlow</code> initiated
with a loan application containing SSN=<%= ssn %></p>
<p>Please refer to the
<a href="/BPELConsole/displayInstance.jsp">BPEL Console</a>
to see the status of the initiated MyLoanFlow BPEL Process.</p>
<%
} %>

Place the cursor over this icon to see the image

Note: The HyperText link for the BPEL Console, added to the feedback code, simplies accessing the Web interface to monitor the BPEL process initiated by the JSP application.

 

5. Save the contents of the invokeMyLoanFlow.jsp file and close the editor.

Back to Topic

Testing the Java UI that Initiates MyLoanFlow

To test the JSP interface that accepts the loan application and initiates MyLoanFlow to process the application, perform the following steps:

1.

To deploy the JSP user interface to Oracle BPEL Process Manager, enter the following commands in a command window:

cd <drive>:\orabpel\samples\tutorials\102.InvokingProcesses
obant

Place the cursor over this icon to see the image

 

2.

To access the JSP application, open a new browser window and enter the following URL:

http://localhost:9700/InvokingProcessesUI/invokeMyLoanFlow.jsp

Place the cursor over this icon to see the image

 

3.

To initiate the MyLoanFlow BPEL process, enter the name Jane Doe (or your own name) in the Customer Name field and click Send Application:

Note: A confirmation page is displayed to indicate that the BPEL process is initiated using the SSN supplied in the HTML form.

 

4.

To view the initiated instance of the MyLoanFlow BPEL process, click the BPEL Console link in the confirmation page:

 

5.

Login to the BPEL Console using the password bpel and click Login:

 

6.

To look at the visual flow of processes for the MyLoanFlow instance, click the nnn: Instance #nnn of MyLoanFlow link in the instance column under the In-Flight BPEL Process Instances 1 - 3 heading:

 

7.

To verify that you are looking at the correct BPEL process instance, click the first receive activity called client (initiate):

Note: An Activity Audit Trail window is opened showing the input received by the BPEL process:

Note: The <input> element contains a <loanApplication> element with the details submitted from the invokeMyLoanFlow.jsp application.

Close the Activity Audit Trail window.

 

8.

Scroll to the end of the visual flow of activities:

Note: The starLoan (onResult) activity is pending completion.

Click the starLoan (onResult) activity to confirm that it is pending completion:

Close the Activity Audit Trail for the activity.

 

9.

To complete the StarLoan task, start a new browser window and enter the following URL:

http://localhost:9700/StarLoanUI

Click the Assign APR Task link.

 

10.

In the Assign APR Task Web page, confirm that the loan application details correspond with the information sent by the invokeMyLoanFlow.jsp application. Click Approve to approve the loan application:

Note: The following confirmation page is displayed indicating that the Assign APR Task has been completed:

Close the browser window.

 

11.

In the browser window with the BPEL Console showing the visual flow of the BPEL process, click the Refresh View link:

 

12.

To confirm that the StarLoan asynchronous process has completed, scroll to the starLoan (initiate) activity and note that it has completed. To view the loan offer selected at the end of the process, scroll to end of the visual flow:

Note: The UnitedLoan loan offer is selected.

 

13.

To view the loan offer returned by the UnitedLoan service, click the client (onResult) activity:

Note: The Activity Audit Trail window displays the XML data for the resulting loan offer from the United Loan:

Close the Activity Audit Trail window, log out of the BPEL Console, and close the browser window.

 

14.

To shutdown Oracle BPEL Process Manager, enter the following commands in a command window:

cd <drive>:\orabpel\bin
shutdownOraBPEL.bat

 

Back to Topic List

In this lesson, you've learned how to:

Create a JSP application with an HTML form interface that submits data supplied to a BPEL process.

Write the Java code to connect with the BPEL Process Manager and initiate a BPEL process using data accepted from an HTML form.

View the activity audit trail of a BPEL process using the visual flow diagram in Oracle BPEL Console.

Back to Topic List

To ask a question about this OBE tutorial, post a query on the OBE Discussion Forum.
To learn more about Oracle BPEL technology, refer to additional OBEs on the OTN Web site

Back to Topic List

Place the cursor over this icon to hide all screenshots.

 

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy