Oracle® BPEL Process Manager Order Booking Tutorial 10g (10.1.3.1.0) Part Number B28987-01 |
|
|
View PDF |
This chapter of the tutorial describes how to add user tasks to handle the manual approval or rejection of a purchase order.
This chapter contains the following topics:
This phase of the tutorial adds to the process you designed in Chapter 10, "Designing the Database Adapter to Insert Data". Ensure that you have successfully completed that phase before performing this one. This phase extends the previous project steps by calling an external manual service through human task capabilities. It includes a call out to another Web service that handles human tasks and uses predefined (default) graphical user interface screens for user actions. You perform the following key tasks:
Create a new BPEL process named OrderApproval.
Design the BPEL process to add workflow functionality to handle the manual approval or rejection of a purchase order.
Deploy the OrderApproval BPEL process.
Run the OrderApproval BPEL process from Oracle BPEL Control.
Access the Oracle BPEL Worklist Application URL to approve the order.
Return to the OrderBooking BPEL process and create a partner link (named POAService) that interacts with the OrderApproval BPEL process.
Design the BPEL process to invoke POAService.
Deploy the OrderBooking BPEL process.
Run the OrderBooking BPEL process from Oracle BPEL Control.
Access the Oracle BPEL Worklist Application URL to approve the order.
This section contains these topics:
In this phase of the tutorial, you create a new project, Order Approval, and define the human workflow process, a sequential workflow in which the order is approved or rejected. The order is first assigned to the Supervisor role. After a user with the Supervisor role approves the order, it is sent to the user's manager for final approval.
This section contains these tasks:
Creating the Order Approval Process and Importing the Schema
Validating, Compiling, and Deploying the Order Approval Process
Summary:
After creating the BPEL process, you import theOrderBookingPO.xsd
schema.In OrderBookingapplication, create an asynchronous BPEL process with the name OrderApproval.
See "Creating the Order Booking Project and Importing the Schema" for a refresher on how to create a project.
Click Next.
Click the flashlight next to Input Schema Element to browse for OrderBookingPO.xsd in
SOA_Oracle_Home\bpel\samples\tutorials\127.OrderBookingTutorial\
OrderApproval\bpel
The Type Chooser window appears.
Expand and select Imported Schemas > OrderBookingPO.xsd > PurchaseOrder.
Click OK.
Click the flashlight next to Output Schema Element and repeat Step 4.
Click Finish.
The schemas are now imported into the project. OrderBookingPO.xsd appears under Order Approval > Integration Content > Schemas in the Application Navigator, and under Schemas in the Structure section. The BPEL process—a Receive activity (receiveInput) and an Invoke activity (callbackClient)—is displayed.
Summary:
When you define the human task, theOrderApproval.task
file—the task configuration metadata file—is created.Select Process Activities from the Component Palette section.
Drag and drop a Human Task activity from the Component Palette to between receiveInput and callbackClient.
Click the Create Task Definition icon (second icon).
Enter OrderApproval for the human task name and click OK. (Accept the default location.)
The OrderApproval.task
file is created.
The Human Task editor is displayed.
For Title, enter Purchase Order Approval.
Accept the default values for Priority and Outcomes.
For Parameters, click the + icon on the right side of the window.
The Add Task Parameter window is displayed.
Click Element and then the flashlight icon.
In the Type Chooser window, expand and select Project Schema Files > OrderBookingPO.xsd > PurchaseOrder, and click OK.
In the Add a Parameter window, click Modifiable via worklist and click OK.
This ensures that you can modify task data using the Oracle BPEL Worklist Application.
In the Assignment and Routing Policy section, click the + icon on the right side of the window.
The Add Participant Type window is displayed.
For Type, select Management Chain.
This participant type routes tasks for approval to multiple users in a management chain hierarchy.
For Label, enter Order Approvers.
Click By name.
In this example, you assign the task to the Supervisor group and specify one level of the management chain above the user who acts on the task.
For Group Id(s), click the flashlight to display the Identity lookup dialog window.
Ensure that your integration server connection is selected.
Ensure that Oracle BPEL Server is running and click Lookup to see a list of all groups currently in the system.
Select Supervisor, click Select, and click OK.
In the Number of Approvers section of the Add Participant Type window, enter 1 in the Maximum Number of Chain Levels Up field. Click OK.
In the Assignment and Routing Policy section, click Enable abrupt completion condition.
The Early Completion Details window is automatically displayed.
Select REJECT and move it to the Selected list. Click OK.
Select Save from the File main menu.
Click the X next to OrderApproval.task to close the Human Task editor.
Summary:
Map the fields to the variables in the BPEL process.Double-click OrderApproval.bpel to see the Human Task activity, OrderApproval_1, in the BPEL process.
Double-click OrderApproval_1.
In the Task Title field, add the word for to the end of the expression Purchase Order Approval.
Click the icon at the right to use the XPath Expression Builder.
In the BPEL Variables section, expand and select inputVariable> payload > ns1:PurchaseOrder > ns1:CustID.
Click Insert Into Expression.
The XPath expression corresponding to ns1:CustID appears in the Expression section.
Click OK.
The XPath expression is appended to the task title.
Click the icon at the right to use the XPath Expression Builder for the Initiator field.
Repeat Steps 5 through 7 to insert the same XPath expression in the Initiator field.
Click the flashlight icon in the BPEL Variable column.
The Task Parameters window appears.
In the Task Parameters window, expand and select Variables > inputVariable > payload > ns1:PurchaseOrder.
Click Insert Into Expression, and click OK.
In the Human Task window, click OK.
Select Save from the File main menu.
Summary:
An autogenerated task form,payload-body.jsp
, is created.In the Application Navigator, right-click the OrderApproval folder that includes the .task
file and select Auto Generate Simple Task Form.
The autogenerated task form file appears:
Close payload-body.jsp by clicking the X sign at the top.
Summary:
The Switch activity reflects the possible outcomes, or cases, specified previously, Approve and Reject. It also has an Otherwise case to represent other outcomes, such as errored, stale, or expired. Inside each of the cases, you can add activities to complete modeling of the business process. The copyPayloadFromTask Assign activities copy the payload back to its source.Double-click OrderApproval.bpel.
Expand the taskSwitch Switch activity.
Drag and drop an Assign activity to below the copyPayloadFromTask Assign activity in the <case Task outcome is APPROVE> section of the Switch activity.
Double-click the Assign icon to display the Assign window.
Click the General tab.
Enter assignOrderApproval1 in the Name field.
Click Apply.
Click the Copy Operation tab.
Click Create and select Copy Operation.
Enter the following details:
Field | Value |
---|---|
From | |
|
Expression |
|
string('Accepted') |
To | |
|
Variable |
|
Select and expand Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderComments
Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. |
Note that the XPath field shows that the expression is set to
/ns1:PurchaseOrder/ns1:OrderInfo/ns1:OrderComments
Click OK to close the Create Copy Operation window and the Assign window.
Repeat Steps 3 through 11 to create an Assign activity below the copyPayloadFromTask Assign activity in the <case Task outcome is REJECT> section. Enter the same details as described above, with the following exceptions:
Name it assignOrderApproval2
Set the Expression field to string('Rejected')
Repeat Steps 3 through 11 to create an Assign Activity below the copyPayloadFromTask Assign activity in the <otherwise> section. Enter the same details as described above, with the following exceptions:
Name it assignOrderApproval3
Set the Expression field to string('Rejected')
Drag and drop an Assign activity from the Component Palette section to below (outside) the Switch activity.
Double-click the Assign icon to display the Assign window.
Click the General tab.
Enter setOutputVariable in the Name field.
Click Apply.
Click the Copy Operation tab.
Click Create and select Copy Operation.
Field | Value |
---|---|
From | |
|
Variable |
|
Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder
Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. |
To | |
|
Variable |
|
Expand and select Variables > outputVariable > payload > ns1:PurchaseOrder |
Click OK to close the Create Copy Operation window and the Assign window.
The process looks as follows:
Select Save from the File main menu.
Click the - sign to close the taskSwitch Switch activity.
Go to the Application Navigator section.
Right-click OrderApproval.
Select Deploy > my_integration_server_connection > Deploy to default domain.
This compiles the BPEL process. Check for errors by clicking the buttons at the bottom of the window. If there are no errors, deployment was successful. If deployment was unsuccessful, see Step 4.
Log into Oracle BPEL Control by selecting Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager > BPEL Control (or refresh the page if it is already open).
Enter the following details to log into Oracle BPEL Control and click Login:
Field | Value |
---|---|
Username | oc4jadmin |
Password | password |
Where password
is the value you entered during installation.
All services are running if the TaskActionHandler and TaskManager services appear in the Dashboard tab.
Click OrderApproval in the Deployed BPEL Processes list.
Enter details in all fields of the HTML Form. You can also use a text editor to copy and paste these details from the contents of the OrderBookingPO_1.xml
file:
Note:
Do not copy and paste from Internet Explorer or Mozilla Firefox. You must use a text editor to perform this task.Click the XML Source radio button.
Copy and paste the contents of OrderBookingPO_1.xml
into the field that appears.
Click Post XML Message.
The BPEL Processes tab displays a message similar to the following:
Test Instance Initiated
Click the Instances tab at the top.
Click the OrderApproval instance.
A message appears indicating that the instance is active.
Select Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager > Sample Worklist Application to access the login window for Oracle BPEL Worklist Application:
Log in as jcooper
/welcome1
.
This displays Oracle BPEL Worklist Application. A task waiting to be approved appears.
Select Claim in the Actions list for the task to approve.
Click Go.
The task details and payload information appear. Since this task is configured to be approved by two users, the task is routed to jstein
, the manager of jcooper
if it is accepted. If the task is rejected, the OrderApproval process identifies the task as rejected and completes processing.
Review the information. For example, the following information appears if you copied and pasted in the contents of OrderBookingPO_1.xml
.
Select Approve from the Task Action list and click Go.
Log out as user jcooper
.
Log into Oracle BPEL Worklist Application as jstein
/welcome1
.
Select Approve from the Actions list and click Go.
After processing, no tasks appear in Oracle BPEL Worklist Application.
Log out.
Return to Oracle BPEL Control.
Click the Instances tab at the top.
Click the OrderApproval instance.
A message appears indicating that the instance has completed.
Click the Audit and Flow links to observe additional details about the completed OrderApproval process.
Summary:
You now create a partner link for the OrderApproval service.Ensure that you are in the OrderBooking process.
Double-click OrderBooking.bpel.
Select Services from the Component Palette section.
Drag and drop a PartnerLink activity from the Component Palette section onto the right side of the designer window.
Enter the following values to create a partner link for the OrderApproval service:
Note:
For the WSDL File field below, click the flashlight (the second icon from the left named Service Explorer) to access the Service Explorer window for automatically selecting the OrderApproval service.Field | Value |
---|---|
Name | POAService |
WSDL File | Access this URL by clicking the Service Explorer flashlight icon and expanding and selecting BPEL Services > my_ integration_server_connection > processes > default > OrderApproval
http://localhost:8888/orabpel/default/OrderApproval/OrderApproval?wsdl See Also: "Setting the Hostname in Your Oracle JDeveloper Web Browser Preferences" if you receive a parsing error when attempting to add a WSDL file in the Service Explorer window. |
Partner Link Type | OrderApproval |
Partner Role | OrderApprovalProvider |
My Role | OrderApprovalRequester |
Click OK.
Select Save from the File main menu.
Summary:
You now create a Scope activity to group all activities that form a logical step to be executed.Drag and drop a Scope activity from the Component Palette section to below the SelectSupplier Switch activity.
Double-click the scope icon to display the Scope window.
Enter UserApproval in the Name field of the General tab.
Click OK.
In this phase of the tutorial, you create the Invoke, Receive, and Assign activities inside this Scope activity.
Click the + sign to expand the Scope activity.
Select Save from the File main menu.
Drag and drop an Invoke activity from the Component Palette section into the UserApproval Scope activity.
Double-click the Invoke icon to display the Invoke window.
Enter the following details:
Field | Value |
---|---|
Name | invokePOAService |
Partner Link | POAService |
The Operation (initiate) field is automatically filled in.
Click the first icon to the right of the Input Variable field. This is the automatic variable creation icon.
Click OK on the Create Variable window that appears.
A variable named invokePOAService_initiate_InputVariable is automatically created in the Input Variable field. This variable is automatically assigned a message type of OrderApprovalRequestMessage.
Click OK.
Drag and drop a Receive activity to below the invokePOAService Invoke activity inside the UserApproval Scope activity.
Double-click the Receive icon to display the Receive window.
Enter the following details:
Field | Value |
---|---|
Name | receivePOAService |
Partner Link | POAService |
The Operation (onResult) field is automatically filled in.
Click the first icon to the right of the Variable field. This is the automatic variable creation icon.
Click OK on the Create Variable window that appears.
A variable named receivePOAService_onResult_InputVariable is automatically created in the Variable field. This variable is automatically assigned a message type of OrderApprovalResponseMessage.
Click OK.
Select Save from the File main menu.
Drag and drop an Assign activity from the Component Palette section to above the invokePOAService Invoke activity and inside the UserApproval Scope activity.
Double-click the Assign icon to display the Assign window.
Enter assignPOADataIn in the Name field of the General tab.
Click Apply.
Click the Copy Operation tab.
Click Create and select Copy Operation to display the Create Copy Operation window.
Field | Value |
---|---|
From | |
|
Variable |
|
Expand and select Variables > inputVariable > payload |
To | |
|
Variable |
|
Expand and select Variables > invokePOAService_initiate_inputVariable > payload |
Click OK to close the Create Copy Operation window and the Assign window.
Select Save from the File main menu.
Drag and drop an Assign activity from the Component Palette section to below the receivePOAService Receive activity and inside the UserApproval Scope activity.
Double-click the Assign icon to display the Assign window.
Enter UserResponse in the Name field of the General tab.
Click Apply.
Click the Copy Operation tab.
Click Create and select Copy Operation to display the Create Copy Operation window.
Field | Value |
---|---|
From | |
|
Variable |
|
Expand and select Variables > receivePOAService_onResult_InputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderComments
Note: The namespace number values (for example, ns1, ns2) can vary. Use the namespace values that automatically appear. |
To | |
|
Variable |
|
Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderStatus |
Click OK.
Click Create and select Copy Operation in the Copy Operation tab again to display the Create Copy Operation window.
Enter the following details to create a second statement:
Note:
Instead of manually entering an expression, you can press Ctrl and then the space bar in the Expression field. Scroll through the list of values that appears and double-click the value you want. Edit the value as necessary. As you enter information, a trailing slash can appear. This means you are being prompted for additional information. Either enter additional information, or press the Esc key and delete the trailing slash to complete the input of information.Field | Value |
---|---|
From | |
|
Expression |
|
concat(bpws:getVariableData('inputVariable','payload','/ns1:PurchaseOrder/ns1:OrderInfo/ns1:OrderComments'), ', User Review Complete') |
To | |
|
Variable |
|
Expand and select Variables > inputVariable > payload > ns1:PurchaseOrder > ns1:OrderInfo > ns1:OrderComments |
Click OK to close the Create Copy Operation window and the Assign window.
When complete, the designer window looks as follows:
Click the - sign to close the UserApproval Scope activity.
Select Save from the File main menu.
Go to the Application Navigator section.
Right-click OrderBooking.
Select Deploy > my_integration_server_connection > Deploy to default domain.
Increment the version number of the project when prompted (for example, enter 1.7) and click OK.
This compiles the BPEL process. Check for errors by clicking the buttons at the bottom of the window. If there are no errors, deployment was successful. If deployment was unsuccessful, see Step 4.
Log into Oracle BPEL Control by selecting Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager > BPEL Control (or refresh the page if it is already open).
Enter the following details to log into Oracle BPEL Control and click Login:
Field | Value |
---|---|
Username | oc4jadmin |
Password | password |
Verify that the processes are deployed (OrderApproval, OrderBooking, and all other processes, including TaskActionHandler). OrderApproval uses TaskActionHandler with a more sophisticated user interaction flow compared to the simpler TaskManager used by SelectManufacturing.
Start the correct OrderBooking version instance in one of the following ways:
Copy SOA_Oracle_Home
\bpel\samples\tutorials\127.OrderBookingTutorial\PracticeFiles
\OrderBookingPO_1.xml
to a temporary directory (drive_letter
:\temp
on Windows operating systems or /temp
on Unix operation systems).
Click the process and provide input to the default graphical user interface page in either of the following ways:
Enter details in all fields of the HTML Form and click Post XML Message.
Click the XML Source radio button. Use a text editor to copy and paste the contents of the OrderBookingPO_1.xml
file into the field that appears. Click Post XML Message.
Open the provided CreateOrderBookingUI application at http://localhost:8888/CreateOrderBookingUI
and provide inputs to initiate a process.
Verify that the OrderBooking process has started.
Provide a price quote for SelectManufacturing from the following graphical user interface:
http://localhost:8888/SelectManufacturingUI
After providing a quote, watch the process instance execute and invoke the user approval service at OrderApproval. Go to Oracle BPEL Control and verify that the OrderApproval process and TaskActionHandler process have both started.
Select Start > All Programs > Oracle - Oracle_Home > Oracle BPEL Process Manager > Sample Worklist Application to access the login window for Oracle BPEL Worklist Application.
Log in as jcooper
/welcome1
. Default users are provided at install time in the following configuration file:
SOA_Oracle_Home\bpel\system\appserver\oc4j\j2ee\home\config\jazn-data.xml
The list shows the task awaiting user actions.
Select Claim in the Actions list and click Go to claim a task.
View the task details, the comments section, and so on.
Approve or reject the task by selecting Accept or Reject from the Task Action list, and click Go.
Log out of user jcooper
. Rejects go directly back to the process, while approved tasks require the next level of approval.
Log in as jstein
/welcome1
(the default manager of jcooper
in the hierarchy defined in the jazn-data.xml
configuration file listed in Step 8).
The list shows the task awaiting user actions.
View the task details, the comments section, and so on.
Approve or reject the task in the Actions list and click Go.
After the jstein
comments, the approved tasks of jcooper
are returned to the process.
View Oracle BPEL Control, database tables, or temporary directory you specified (drive_letter
:\temp
on Windows operating systems or /temp
on Unix operation systems) for completion of the process (as examined in previous tutorial phases).
You have now added user tasks to handle the manual approval or rejection of a purchase order. This phase extended the previous project steps by calling an external manual service through human task capabilities. It included a call out to another service that handled human tasks and used predefined (default) graphical user interface screens for user actions. You performed the following key tasks:
Created a new BPEL process named OrderApproval.
Designed the BPEL process to add workflow functionality to handle the manual approval or rejection of a purchase order.
Deployed the OrderApproval BPEL process.
Ran the OrderApproval BPEL process from Oracle BPEL Control.
Accessed the Oracle BPEL Worklist Application URL to approve the order.
Returned to the OrderBooking BPEL process and created a partner link (named POAService) that interacted with the OrderApproval BPEL process.
Designed the BPEL process to invoke POAService.
Deployed the OrderBooking BPEL process.
Ran the OrderBooking BPEL process from Oracle BPEL Control.
Accessed the Oracle BPEL Worklist Application URL to approve the order.