This article will give you a basic knowledge of workflow and show you how to implement it using IBM® WebSphere® Process Choreographer, which is a component of WebSphere Studio Application Developer Integration Edition V5.1. The article will also show you how to integrate a Process Choreographer workflow with a Web service.
To run the examples in this article, you will need WebSphere Studio Application Developer Integration Edition V5.1 (hereafter called Application Developer), with the latest software updates installed.
ChocoDino, Inc.
![]() | In 1989, Kwesi Gadzi and his family emigrated from Ghana to Brooklyn, New York. After spending ten years as a programmer he decided to start his own business. Kwesi noticed that his children liked chocolate. They liked dinosaurs. So he started a company, ChocoDino, Inc., that manufactured and sold chocolates shaped like dinosaurs. He now sells four different types of chocolate dinosaurs:
|
As ChocoDino, Inc, grew, Kwesi decided that he needed an ordering process for his chocolates. You will implement this business process for him using WebSphere Process Choreographer.
At the end of this article, you should be able to use WebSphere Process Choreographer to:
- Create a simple chocolate dinosaur ordering process using the Services and Business Process wizards.
- Add Receive, Reply, Assign, Invoke, and Switch Activities to a chocolate dinosaur business process.
- Understand how to include a child business process as part of a parent business process.
- Include Web services as part of the chocolate dinosaur business process.
- Configure and use a Staff Activity which will let Kwesi interact with your business process.
- Feel comfortable navigating through the Business Process Editor and Perspective using Application Developer.
- Identify the various design patterns throughout the development of the ChocoDino business process.
Overview: ChocoDino order process
Business Process Execution Language for Web Services (BPEL4WS) is a language for specifying the behavior of business processes. BPEL4WS expands the Web services interaction model and enables it to support business transactions. WebSphere Process Choreographer implements the BPEL4WS standard and offers important additions such as Staff Activity and Java Snippet. A Staff Activity allows human interaction with your workflow, while a Java Snippet lets you add Java code to your business process.
All variables, partner links, and activities in this article begin with at capital letter. Assignment activities used for setup begin with a lowercase letter. While this convention is not a standard, it's a good practice because it highlights the relevant business activities.
In this article, you will use BPEL4WS to build a Chocolate Dinosaur Order Process using Application Developer. This process will accept an order for chocolate dinosaurs as input. A Chocolate Dinosaur Order consists of a customer number, an item number corresponding to one of the four chocolate dinosaur types, a unique order identifier, and the quantity of chocolate dinosaurs. The business process will process the order by performing the following tasks:
- Attempt to fulfill the order for chocolate dinosaurs.
- If the order is fulfilled, ship the chocolate dinosaurs and bill the customer.
The output of this process will be an order-completed status flag set to true or false
and a comment regarding order status. At the end of the article you will have built the main Chocolate Dinosaur Order Process
and its child Fulfill Chocolate Dinosaur Order Process. They are represented in the following diagrams:
| Chocolate Dinosaur Order Process | Fulfill Chocolate Dinosaur Order Process |
![]() | ![]() |
Launch Application Developer. From the Start menu, select Programs => IBM WebSphere Studio => Application Developer Integration Edition.
A dialog box will open, where you can select where you want the workspace directory to be stored.
Enter <drive_letter>\chocodino\workspace for the location
and click OK. Application Developer will start with an empty workspace.
Now you must enable server targeting support. Select Window => Preferences and click on J2EE in the navigation frame of the window that opens, then select Enable server targeting support and click OK.
Figure 1. Enable server targeting support

In the Tasks view, click Filters
. Select
On selected resource and its children, which will limit the messages displayed in the Tasks view to the ones pertinent to your component.
Figure 2. On selected resource and its children

In the Services View, right-click on Service Projects and select New => Service Project. Use the Project name
ChocoDino, and leave the defaults (project location) as-is. Click Finish.
Figure 3. Create a new project named ChocoDino

Creating the initial business process
Create a new sequential business process
You will build the ProcessChocoDinoOrder process containing the three main steps as defined in the Overview:
- Track the fulfillment of the order for chocolate dinosaurs until the order is fulfilled.
- Ship the order of chocolate dinosaurs.
- Bill the customer.
Right-click on ChocoDino project and select New => Business Process. Enter com.chocodino.process for Package. Enter ProcessChocoDinoOrder> for File name. Click Next.
Figure 4. Create a new ProcessChocoDinoOrder

Create a sequence-based process
The two types of business processes used in this project will be sequence and flow based. The ProcessChocoDinoOrder is
a Sequence-based BPEL Process. Click Finish. The ProcessChocoDinoOrder.bpel
business process will open up in the Process Editor.
Figure 5. Sequence based Process

Configure the service interface
You must define the process interface for your business process. This is the service interface for others to interact with this process. Create a new Port Type for the process.
In the Services view, double click the ProcessChocoDinoOrderInterface.wsdl file to open it. Under Port Types,
right-click and select Add Child => Port Type.
Name the port ProcessOrderPortType
Enter ProcessOrderPortType for the Name and click OK.
Select the ProcessOrderPortType port type that you just created. Right-click and select Add Child => Operation.
Enter processOrder and click OK.
Create the processOrderRequest message
Select the processOrder operation. Right-click and select Add Child => Input. Select the input parameter. Right-click and select Set Message. Leave the default value, processOrderRequest, and click Finish.
Repeat the steps to add the output and processOrderResponse parameters to the processOrder operation.
Figure 6. Create processOrderRequest

Under Messages, you should have two new messages, processOrderRequest and processOrderResponse.
Figure 7. Messages processOrderRequest and processOrderResponse

Add parts to processOrderRequest message
Select the processOrderRequest message. Right-click and select Add Child => Part. Enter customerId and click OK.
Repeat and add the parts for orderId, itemId and quantity.
| processOrderRequest Parts | Type | What this field is used for by ChocoDino, Inc. |
|---|---|---|
| customerId | xsd:string | Kwesi assigns each customer account a unique number. For example, Betsy's Sweet Shop in Long Island, is assigned the customer id of
1000-01. |
| orderId | xsd:string | Every order received by ChocoDino, Inc. is assigned a unique tracking number. |
| itemId | xsd:string | Each of the four products is assigned a unique item number:
|
| quantity | xsd:int | The quantity of one of the four products above (itemId) that will be shipped to the customer. |
Change quantity to xsd:int type
To change the type of the quantity variable, select the quantity part. Right-click and choose Set Type. Set the Type to an existing one,
xsd:int.
Figure 8. Set quantity to xsd:int type.

Add parts to processOrderResponse message
Add the following parts to the message processOrderResponse: isComplete of type xsd:boolean and comment of type
xsd:string.
| processOrderResponse Parts | Type | What this field is used for by ChocoDino, Inc. |
|---|---|---|
| isComplete | xsd:boolean | Was the ordered completed? If so then the correct quantity of chocolate dinosaurs were shipped to the customer. |
| comment | xsd:string | A message that should be included with the shipment. |
Completed ProcessChocoDinoOrderInterface.wsdl
Your ProcessChocoDinoOrderInterface.wsdl should resemble the graphic below. Save your changes by clicking Ctrl-S.
Figure 9. Completed ProcessChocoDinoOrderInterface.wsdl

In the Services view, open the ProcessChocoDinoOrder.bpel business process. Select the ProcessChocoDinoOrder node. In the details pane, scroll down to the Server tab. Select the Process is long-running check box. This indicates that the process is interruptible. Set the Target namespace to http://www.chocodino.com, the URL for ChocoDino, Inc. Click Ctrl-S. You will see the warning "The deployment code for this process needs to be generated." This will be resolved when you deploy your process in a later step.
Figure 10. Server tab in ProcessChocoDinoOrder.bpel

Configure the process interface
Configure the process interface to the one you created in ProcessChocoDinoOrderInterface.wsdl. This is done by associating
the process Receive and Reply activities with the interface definition of a Partner. You will create a ProcessOrder partner that uses the
ProcessOrderInterface as the process port type. Setup the Partner and Partner link for the business process.
Right-click and select the default PartnerLink on the top right to rename it to ProcessOrder.
In the details property pane, switch to the Description page. The Name should be set to ProcessOrder.
Still in the details pane, switch to the Implementation tab, and click New next to the Partner Link Type.
The New Partner Link Type definition box will open with a new Partner Link Type of ProcessOrderPLT. Leave the Number of
Roles as One Role, and enter the First Role as ProcessOrderFirstRole.
Figure 11. Enter the ProcessOrderFirstRole

Click Browse next to Port Type File and navigate to ChocoDino => com => chocodino => process => ProcessChocoDinoOrderInterface.wsdl. Select ProcessOrderPortType for the Port Type. Click OK.
Your Partner Link panel should resemble the one shown below. Click OK.
Figure 12. Partner link panel

You are defining the interface (Port Type) into your process so you must swap the roles. The Process Role/Port Type is for those that wish to send messages into your process. As a default, the previously defined role is assigned to sending messages out to a partner. In most cases the Partner Link Type would be the right assumption.
With the ProcessOrder partner still selected on the layout area, switch to the Implementation tab. Swap the Partner's Role with the Process Role using the <---> button. Type Ctrl-S to save the changes.
Figure 13. Swap the Partner's Role with the Process Role

Set up the Receive to handle the correct messages
Select the Receive activity and switch to the Implementation tab. The Partner Link should be ProcessOrder and the Port Type must have ProcessOrderPortType selected. Use the drop down menu to select processOrder as the Operation.
For the Request, click New and enter ProcessOrderRequest. Click OK.
Set up the Reply to handle the correct messages
Select the Reply activity and switch to the Implementation tab. The Partner Link should again be ProcessOrder and the Port Type must be ProcessOrderPortType. Use the drop down menu to select processOrder as the Operation.
For the Response message, click New and enter ProcessOrderResponse. Click OK.
In the diagram, delete the variable placeholder, InputVariable, from the Variables list.
Figure 14. Enter a new response variable - ProcessOrderResponse

Adding an activity to the business process
Add an Assign activity
![]() | You have created the initial framework for a business process - a Receive and a Reply. Now you can add activities. Your business process accepts four parameters: customerId, orderId, itemId and quantity as the input (through the Receive activity).
The business process will reply with a Choose an Assign activity (the "=" sign) from the Palette and drop it in between the Receive and Reply activities in your business process. |
Rename the Assign activity to prepReply
Rename the activity to prepReply. Your business process will now look like the one below.
Figure 15. Rename the activity to prepReply

Add fixed comment to the Reply message
Select the prepReply activity that you just added. Switch to the Implementation tab. Using the From dropdown box,
select Fixed Value and enter ChocoDino order completed by Kwesi as the value. Using the To dropdown, select
Variable or Part. Choose ProcessOrderResponse => comment.
Figure 16. Assign "ChocoDino order completed by Kwesi" to comment

Add isComplete to the Reply message
Click New. Using the From dropdown box, select Fixed Value and enter false as the value. Choose the
type xsd:boolean. Using the To dropdown, select Variable or Part. Choose ProcessOrderResponse => isComplete.
Click Ctrl-S to save your changes.
Figure 17. Assign false to isComplete variable

Generating the deployment code
Generate the deployment code for ProcessChocoDinoOrder
In the Services view, expand com.chocodino.process and right-click on
ProcessChocoDinoOrder.bpel and select Enterprise Services => Generate Deploy Code.
The Generate BPEL Deploy Code wizard opens up. By default the process will be exposed through a JMS interface binding only. JMS is used for any long running business process. If you had not selected the Process is long-running check box then you would have been offered a choice of an EJB (default), JMS, SOAP/HTTP or SOAP/JMS binding. The strength of WebSphere Process Choreographer is that it can implement both long running persistent workflows and non-persistent microflows.
Click OK to generate the deployment code for your project.
Inspect the deployed code for ProcessChocoDinoOrder
After the deployed code has been generated, switch to the J2EE Hierarchy view by clicking the tab in the Navigator pane.
Expand EJB Modules = ChocoDinoEJB => Session Beans. The ProcessChocoDinoOrderBean is the EJB containing
your business process.
Figure 18. Deployed ProcessChocoDinoOrderBean code

Using the unit test environment
Create a server and server configuration
Select the Servers tab at the bottom. This is located near the Tasks tab. Right-click in the pane and
select New => Server and Server Configuration. Name the server TestServer. Make sure
that Server Type is WebSphere version 5.1 => Integration Test Environment. click Finish.
Add the business process EAR to the test server. Right-click on the TestServer in the Servers
view and select Add and Remove Projects. Add the ChocoDinoEAR to the Configured projects. Click Finish.
Figure 19. Add ChocoDinoEAR to list of configured projects

Create tables and datasources, then publish!
Create tables and datasources. Right-click on TestServer again and select Create tables and datasources. click OK on the completion dialog after checking that the tables were created successfully.
Right-click TestServer and select Publish. Click OK to dismiss the "Publishing was successful" dialog. Verify that the process was deployed. Right-click on TestServer in the Servers view. Choose Show deployed processes. This should open the Deployed Processes view and your process should be shown there. This action can only be done when the server is stopped.
Figure 20. The deployed process ProcessChocoDinoOrder

Using the business process Web client
Return to the Servers view, right-click on the TestServer. Select Start.
Once the server has started, you will test the process using the Business Process Web Client. In the Servers view, right-click TestServer and
select Launch Business Process Web Client. The Business Process Web Client will open in a Web browser view window.
You can also open the Web client from an external browser using the address http://localhost:9080/bpe/webclient.
Click on the My Templates link in the left column of the Web Client.
The process ProcessChocoDinoOrder should be listed, with a state icon of
Running
.
Click the ProcessChocoDinoOrder Template Name link. The template definition is displayed for your review. The processOrder service that you implemented is listed.
Figure 21. The processOrder service

Select the processOrder service link. The Process Input Message panel is displayed. Enter the following values. The Process Instance Name must be
unique. Enter Test1. Betsy's Sweet Shop (customer id 1000-01) orders 100 Braciosaurs Brownies (item id 400). Choose orderId as 1.
| Process Input Message | Value |
|---|---|
| customerId | 1000-01 |
| itemId | 400 |
| orderId | 1 |
| quantity | 100 |
Click
. The Process Instance will
execute. Select the Created By Me link in the left column of the Web Client. Click the Test1 process link. The Response value
of isComplete is set to false. The comment is set to ChocoDino order completed by Kwesi.
Figure 22. Result of Test1 execution

Close the Web Client. From the Servers view, right-click on the TestServer. Select Stop from the menu.
Implementing Web services with WebSphere Process Choreographer
![]() |
Kwesi decides to use Web services to interface his business process with other software components he uses at ChocoDino, Inc. The two Web services calls that he will be implementing are for shipping and billing. Prior to the development of those Web services, you should generate a stub class. First create the Java class to implement the business logic. Then generate the Web services for the class. |
In the Services view, right-click on the ChocoDino service project and select New => Package. Enter com.chocodino.model for the package name. Click Finish to create the package
Figure 23. Create the com.chocodino.model package

Create the OrderProcessing class
Right-click on the newly created package and select New => Class. Enter OrderProcessing as the class name.
Click Finish. Add the methods below to the OrderProcessing class. Save the changes using Ctrl-S.
/**
* Stub method for shipping order
*/
public boolean shipOrder(String chocoCustomerId, String dinoOrderId) {
System.out.println(
"ChocoDino shipping order "
+ dinoOrderId
+ " to customer " + chocoCustomerId);
return true;
}
/**
* Stub method for billing customer
*/
public boolean billCustomer(String chocoCustomerId, String dinoOrderId) {
System.out.println(
"ChocoDino billing customer "
+ chocoCustomerId
+ " for order " + dinoOrderId);
return true;
}
|
Generate the Web services for OrderProcessing
In the Services View, select OrderProcessing.java. Using the menu bar, select File => New => Service built from. The diagram shows the two choices for creating a service: Java or EJB. In this case you are using a Java class. Click Next. Check the box for OrderProcessing and click Next.
Figure 24. Generate Web services for OrderProcessing java

Change the package name to com.chocodino.wsdl. Click Finish to generate the WSDL file.
Figure 25. Change the package name to com.chocodino.wsdl

Developing the initial ChocoDino fulfillment business process
Fulfilling the order for chocolate dinosaurs
![]() |
Create a new milestone business process for Fulfilling Chocolate Dinosaur orders. This business process will involve a Staff activity. Kwesi must check his stock of chocolate dinosaurs to determine if a customer's order can be completed. This business process will use the OrderProcessing Web services that you just created. |
Create the Fulfill ChocoDino Order process
From the menu, choose File => Close All. Right-click on ChocoDino project and select New => Business Process. In the package
com.chocodino.process, create the new business process named FulfillChocoDinoOrder
(note spelling). Click Next.
Figure 26. Create the FulfillChocoDinoOrder business process

Select Flow-based BPEL Process for process type and click Finish.
Figure 27. Flow-based BPEL Process

Add port, messages, and parts to FulfillChocoDinoOrderInterface.wsdl
Open FulfillChocoDinoOrderInterface.wsdl. Create a new Port Type service interface, FulfillOrderPortType, for the process with the details as shown below.
Figure 28. Details of FulfillChocoDinoOrderInterface.wsdl

| fulfillOrderRequest Parts | Value |
|---|---|
| orderId | xsd:string |
| itemId | xsd:string |
| quantity | xsd:int |
| fulfillOrderResponse Parts | Value |
|---|---|
| isComplete | xsd:boolean |
| fulfilledQuantity | xsd:int |
You can change the Parts type for entries such as quantity using the Parts menu.
Select the quantity part in the Messages window and use the Part Type dropdown to select xsd:int.
Click Ctrl-S to save your changes. Close the FulfillChocoDinoOrderInterface.wsdl.
Figure 29. Set quantity as xsd:int

Process parameters for FulfillChocoDinoOrder.bpel
Open FulfillChocoDinoOrder.bpel. Setup the Process parameters.
Select the FulfillChocoDinoOrder node and choose the Server tab. Change the target namespace to http://www.chocodino.com.
You must denote this process as long running because in a subsequent section you will add a Staff activity.
Figure 30. Set Process parameters in FulfillChocoDinoOrder.bpel

Rename partner link to FulfillOrder and configure process interface
Rename the default PartnerLink to FulfillOrder. From the Implementation tab, configure the process interface to
use the new FulfillOrderPortType. Remember to browse to your new FulfillChocoDinoOrderInterface.wsdl and swap the roles so
that FulfillOrderFirstRole is a Process Role.
Figure 31. Configure the process interface to use the new FulfillOrderPortType

Set up the Receive and Reply activities
Set up the Receive and Reply activities to correlate with the new messages. In the Receive activity you should create a FulfillOrderRequest variable. In the Reply activity you need a FulfillOrderResponse variable. Delete the default InputVariable. The operation for both Receive and Reply is fulfillOrder.
| Receive FulfillOrderRequest fields |
|---|
| orderId |
| itemId |
| quantity |
| Reply FulfillOrderResponse fields |
|---|
| isComplete |
| fulfilledQuantity |
Right-click on the Reply activity. Choose Insert Before => Assign. Rename this assignment prepReply.
Figure 32. Context menu for Insert Before => Assign

In prepReply, select the Implementation tab. Assign a fix value true of type xsd:boolean to the isComplete part of the FulfillOrderResponse.
Assign the quantity part of the FulfillOrderRequest to the fulfilledQuantity part of the FulfillOrderResponse. Remember to remove the default InputVariable.
| From | To |
|---|---|
true (xsd:boolean) | FulfillOrderResponse > isComplete |
FulfillOrderRequest > quantity | FulfillOrderResponse > fulfilledQuantity |
Save your business process by clicking Ctrl-S.
Two separate execution threads
In the diagram, drag the three components into three separate columns as shown below. Since this is a Flow diagram, the Assign and the Receive/Reply have separate execution threads. You want these operations to occur in sequence and you will wire them together in the next panel.
Figure 33. Assign and the Receive/Reply have separate execution threads

Create a sequential path through a flow diagram
Delete the line connecting the Receive and Reply activities.
Click on Receive and then the arrow
next to Receive.
Drag the connector to the prepReply. Repeat this step for the prepReply to Reply. This is now a sequential path through the Flow diagram.
Figure 34. Sequential path through the Flow

Complete the FulfillChocoDinoOrder flow
At this point your FulfillChocoDinoOrder diagram should resemble the following figure.
Figure 35. FulfillChocoDinoOrder diagram prior to testing

Generate the deployment code for FulfillChocoDinoOrder
In the Services view, expand com.chocodino.process and right-click on
FulfillChocoDinoOrder.bpel and select Enterprise Services => Generate Deploy Code.
The Generate BPEL Deploy Code wizard opens up. The process will be exposed through a JMS interface binding. JMS is used for any long running business process.
Click OK to generate the deployment code for your project.
Create tables and datasources and publish the project
Right-click on TestServer and select Create tables and datasources. click OK on the completion dialog after checking that the tables were created successfully.
Right-click TestServer and select Publish. Click OK to dismiss the "Publishing was successful" dialog.
Right-click on the TestServer. Select Start
Figure 36. The deployed process FulfillChocoDinoOrder and ProcessChocoDinoOrder

Use the Business Process Web Client to test FulfillChocoDinoOrder
Return to the Servers view, right-click on the TestServer. Select Start.
Once the server has started, you will test the process using the Business Process Web Client. In the Servers view, right-click TestServer and select Launch Business Process Web Client. The Business Process Web Client will open itself in a Web browser view window.
Click on the My Templates link in the left column of the Web Client.
The process FulfillChocoDinoOrder should be listed. Click the FulfillChocoDinoOrder Template Name link. The template definition is displayed for your review. The fulfillOrder service that you implemented is listed.
Figure 37. The fulfillOrder service

Enter ChocoDino fulfillOrder data
Select the fulfillOrder service link. Enter the following values in the Process Input Message panel.
The Process Instance Name must be unique. Enter Test2. Betsy's Sweet Shop orders 100 Braciosaurs Brownies (item id 400). Choose orderId as 1.
| Process Input Message | Value |
|---|---|
| itemId | 400 |
| orderId | 1 |
| quantity | 100 |
Figure 38. Entry of Test2 variables

Completed ChocoDino fulfillOrder data
Click
.
The Process Instance will execute. Select Created By Me in the left column of the Web Client. Click the Test2 process instance link.
The Response value of isComplete is set to true. The fulfilledQuantity is 100.
Figure 39. Result of Test2 execution

Close the Web Client. From the Servers view, right-click on the TestServer. Select Stop.
Completing the ProcessChocoDinoOrder business process
Review of ProcessChocoDinoOrder
Continue developing the ProcessChocoDinoOrder by adding all the activities needed to complete the business process. This will include interfacing with a Web service for the Ship order of chocolate dinosaurs and Bill customer parts. The Dinosaur fulfillment process is a child business process, FulfillChocoDinoOrder. The completed ProcessChocoDinoOrder process should resemble the design diagram.
Figure 40. Chocolate Dinosaur Order Process

Add the FulfillChocoDinoOrder process
Add the FulfillChocoDinoOrder child process to the ProcessChocoDinoOrder process. From the menu, choose File => Close All.
In the Services view, double click on ProcessChocoDinoOrder.bpel to open it. Select FulfillChocoDinoOrder.bpel from the Services view and drag it onto the process editor. It will relocate under the Partner Links.
Save the changes by clicking Ctrl-S.
Figure 41. Add FulfillChocoDinoOrder to Partner Links

Insert the FulfillOrder activity to the ProcessChocoDinoOrder process by adding an Invoke activity below the Receive activity. Rename
it to FulfillOrder.
Select the FulfillOrder activity. Right-click and choose Set Partner Link. Drag the arrow and drop it on the FulfillChocoDinoOrder Partner Link.
With the FulfillOrder Invoke activity still selected, switch to the Implementation tab. Use the dropdown list to set the Partner Link to FulfillChocoDinoOrder. Select fulfillOrder for the Operation.
Click New for the request and enter FulfillOrderRequest and click OK.
Click New for the response and enter FulfillOrderResponse and click OK.
Save the changes using Ctrl-S.
Figure 42. FulfillOrder Implementation
Add the prepFulfillOrder activity
![]() |
Add an Assign activity before FulfillOrder and rename it to With the prepFulfillOrder activity selected, switch to the Implementation tab. Assign from the ProcessOrderRequest to the FulfillOrderRequest the orderId, itemId and quantity variables. Click New to create a new mapping pair for each assignment. Save the changes using Ctrl-S. Even though FulfillOrderRequest uses the same part names as and is a subset of the ProcessOrderRequest you must create a new request variable for each invoke. |
| ProcessOrderRequest | FulfillOrderRequest |
|---|---|
orderId | orderId |
itemId | itemId |
quantity | quantity |
Modify the prepReply activity to use the result of the FulfillOrder
Since the FulFillOrder has been implemented the prepReply activity should use the result. Assign the isComplete part from the FulfillOrderResponse to the ProcessOrderResponse. Save your changes by clicking Ctrl-S.
Figure 43. Assign the isComplete part

Add OrderProcessing Web service
Add the OrderProcessing Web service to ProcessChocoDinoOrder. Use the OrderProcessing Web service, created from the stub Java class. This will allow you to invoke the two service calls, ShipOrder and BillCustomer from ProcessChocoDinoOrder.
Under Services, select OrderProcessingJava Service.wsdl and drag it onto the process editor.
Click OK to add the OrderProcessing to the Partner Links.
Save the changes using Ctrl-S.
Figure 44. Add OrderProcessing Web Service

Insert a Switch activity after the FulfillOrder activity.
Figure 45. Add Switch

Add a Case to the Switch activity.
Kwesi only wants to ship the chocolates and bill his customer if he has completed the order. If the order is not
completed, then the ProcessChocoDinoOrder should return back to the calling process with isCompleted set to
false. The calling process will then determine what went wrong and either resubmit the order or notify the customer
that their order of delicious chocolate dinosaurs cannot be processed.
Select the Case and its Description tab. Rename the Case to FulfillOrderCompleted.
Click the Condition tab. Select Exclickion for the value and enter the following. Remember Kwesi only wants to ship the chocolate dinosaurs and bill the customer if the order was completed.
// only ship the chocolates and bill the customer if the order is completed return getFulfillOrderResponse().getIsComplete(); |
Notice that the BPEL4WS variable, FulfillOrderResponse, is implemented as a Java class.
Save the changes using Ctrl-S.
Implicit in the Switch statement is that if isCompleted is set to false then the Reply activity will be invoked.
Contents of the Switch statement
Use the figure below as a guide for the next several steps.
Figure 46. The Switch statement and its contents.

Add ShipOrder to invoke the Web service
Add an Invoke activity. Rename it to ShipOrder.
Select the activity. Choose the Set Partner Link icon
.
Drag the arrow and drop it on the OrderProcessing Partner Link.
Select ShipOrder. Switch to the Implementation tab. Choose shipOrder for the Operation.
Click New to create a request variable, ShipOrderRequest, and a response variable, ShipOrderResponse.
Click Ctrl-S.
Figure 47. ShipOrder Implementation

Add an Assign activity and rename it to prepShipOrder.
With the prepShipOrder activity selected, switch to the Implementation tab.
Assign the fields from the ProcessOrderRequest to the ShipOrderRequest. Click New to create a new mapping pair.
| ProcessOrderRequest | ShipOrderRequest |
|---|---|
customerId | chocoCustomerId |
orderId | dinoOrderId |
Add BillCustomer to invoke the Web service
Add an Invoke activity. Rename it to BillCustomer.
Select the activity. Choose the Set Partner Link icon
.
Drag the arrow and drop it on the OrderProcessing Partner Link.
Figure 48. BillCustomer Partner Link

With the BillCustomer activity still selected, switch to the Implementation tab. Choose billCustomer for the Operation.
Click New to create a request variable, BillCustomerRequest, and a response variable, BillCustomerResponse.
Click Ctrl-S to save your changes.
Add an Assign activity and rename it to prepBillCustomer.
Select prepBillCustomer activity. Switch to the Implementation tab.
Assign the fields from the ProcessOrderRequest to the BillCustomerRequest. Click New to create a new mapping pair.
| ProcessOrderRequest | BillCustomerRequest |
|---|---|
customerId | chocoCustomerId |
orderId | dinoOrderId |
Create tables and datasources, then publish and use the Web client
Right-click on TestServer and select Create tables and datasources. Click OK on the completion dialog after checking that the tables were created successfully.
Right-click TestServer and select Publish. Click OK to dismiss the "Publishing was successful" dialog.
Right-click on the TestServer. Select Start
Test the ProcessChocoDinoOrder using the Business Process Web Client.
Completing the FulfillChocoDinoOrder business process
Overview of FulfillChocoDinoOrder
![]() |
Continue the development the FulfillChocoDinoOrder by adding all the activities needed to complete the business process. This will include implementing a Staff activity. The completed FulfillChocoDinoOrder process should look like the design diagram. This portion will implement two Assign activities, a while loop, a Staff activity and a Java Snippet. |
Modify the FulfillChocoDinoOrderInterface.wsdl
A Staff activity allows human interaction with your business process. Staff is an important part of workflow.
From the menu choose File => Close All. Open FulfillChocoDinoOrderInterface.wsdl.
Modify the FulfillChocoDinoOrderInterface.wsdl file by adding the StaffPortType as shown below
Figure 49. Add the StaffPortType

Add the RetrieveItems Staff activity
Open FulfillChocoDinoOrder.bpel. Add a Staff activity. Since this is a flow diagram it will have a separate thread.
Rename it RetrieveItems.
Select the Implementation tab.
Browse to FulfillChocoDinoOrderInterface.wsdl. Use the StaffPortType and select the retrieveItem operation.
Click New for the request and enter RetrieveItemsRequest. click OK.
Add RetrieveItemsResponse for the response.
Click the Staff tab. Modify each role so that the Verb is Everybody. This will allow all employees of ChocoDino to perform the Potential Owner, Editor and Reader staff operations. In a larger company, you would differentiate these roles to particular users.
Save the changes using Ctrl-S. You will see several errors by these will be resolved in a subsequent step.
Figure 50. RetrieveItems Implementation

Add a While Order is Not Fulfilled loop
Add a While activity. Rename it to WhileNotFulfilled. This loop will execute until the order is considered fulfilled by Kwesi.
If Kwesi has the correct quantity and type of chocolate dinosaurs available then the order is considered both fulfilled and completed.
If he does not have the items in stock Kwesi can either:
- Enter the quantity of chocolates that he does have in stock and consider the order fulfilled. The isComplete flag will be
set to
falseand a log message will be written in the Java Snippet step below. The parent process will be responsible for notifying the ChocoDino customer that their order cannot be completed with a shipment of tasty chocolates. - Set the isFulfilled flag to
false. This will allow him to return to the order at a later date when he can ship the correct number of chocolates for the order.
Select the Condition tab and the Exclickion dropdown menu for the value. Enter the following exclickion.
// continue prompting Kwesi until the order is considered fulfilled. return !getRetrieveItemsResponse().getIsFulfilled(); |
Move the RetrieveItems staff activity inside of the loop.
Click Ctrl-S.
Figure 51. Add the WhileNotFulfilled

Add an Assign activity and rename it to prepNotFulfilled.
With the prepNotFulfilled activity selected, switch to the Implementation tab.
Assign the fields as shown below. This has a substantial number of assignments to different variables so be careful.
| From [Fixed Value] | To |
|---|---|
0 (xsd:int) | FulfillOrderResponse > fulfillQuantity |
0 (xsd:int) | RetrieveItemsRequest > quantityRetrieved |
0 (xsd:int) | RetrieveItemsResponse > quantityFilled |
false (xsd:boolean) | RetrieveItemsResponse > isFulfilled |
| From | To |
|---|---|
FulfillOrderRequest > orderId | RetrieveItemsRequest > orderId |
FulfillOrderRequest > itemId | RetrieveItemsRequest > ItemId |
FulfillOrderRequest > quantity | RetrieveItemsRequest > quantityNeeded |
Add another Assign activity. Rename it to postRetrieveItems.
Switch to the Implementation tab.
Assign the fields as shown below.
| From | To |
|---|---|
RetrieveItemsResponse > quantityFilled | RetrieveItemsRequest > quantityRetrieved |
RetrieveItemsResponse > quantityFilled | FulfillOrderResponse > fulfillQuantity |
Move the postRetrieveItems inside of the while loop under the Staff activity.
Replace the prepReply with a Java Snippet
Delete the prepReply activity and replace it with a Java Snippet. Name it prepReply.
Select the Implementation tab. Kwesi wants to set the isCompleted flag to true if the requested number of chocolate dinosaurs is what he
scan deliver to the customer. Otherwise the response isCompleted flag is set to false. If the order is not completed the process must log an audit message. This will allow him to adjust his chocolate dinosaur inventory.
// set isCompleted flag based on requested # of chocolate dinosaurs vs. what is delivered
getFulfillOrderResponse(true).setIsComplete(getFulfillOrderRequest().getQuantity()
<= getRetrieveItemsResponse().getQuantityFilled());
// log a audit message if the order is not completed
if (!getFulfillOrderResponse().getIsComplete())
{
System.out.println("Order was not fulfilled for : " + getFulfillOrderRequest().getOrderId());
}
|
Complete the FulfillChocoDinoOrder
Move the activities and wire them as shown in the diagram.
Configure the FulfillChocoDinoOrder process for proper Staff interaction. Select the FulfillChocoDinoOrder node at the top.
Select the Staff tab. Select each role and change the verb to Everybody.
Save the changes using Ctrl-S.
Repeat the same Staff steps for the parent ProcessChocoDinoOrder business process.
Figure 52. Completed FulfillChocoDinoOrder

Testing the ProcessChocoDinoOrder process
Build project and start testing
Generate the deployment code for both FulfillChocoDinoOrder.bpel and ProcessChocoDinoOrder.bpel.
Create the tables and datasources.
Publish and start the TestServer.
Test the ProcessChocoDinoOrder business process using the Business Process Web Client. This business process will have a staff activity. In the Servers view, right-click TestServer and select Launch Business Process Web Client.
Click on My Templates in the left column of the Web Client. The process FulfillChocoDinoOrder and ProcessChocoDinoOrder should be listed,
with a state icon of Running
.
Click ProcessChocoDinoOrder Template Name. The template definition is displayed for your review. The processOrder service that you implemented is listed.
Figure 53. The processOrder service

Click on the processOrder link. The Process Input Message panel is displayed.
Enter Test3. Betsy's Sweet Shop (customer id 1000-01) orders 100
Braciosaurs Brownies (item id 400). Choose orderId as 2.
| Process Input Message | Value |
|---|---|
| customerId | 1000-01 |
| itemId | 400 |
| orderId | 2 |
| quantity | 100 |
Click
. The Process Instance will execute.
Build project and start testing
Select My To Dos link in the left column. This will list any staff activities.
Figure 54. The processOrder service

Click the RetrieveItems link.
Figure 55. RetrieveItems in Ready state

Since you need to fulfill this order, click
. You will be returned to My To Dos.
Figure 56. RetrieveItems in Claimed state

Click on the RetrieveItems link. You will see the following. Enter true for isFulfilled and 100
for the quantityFilled. Click
.
Figure 57. Enter data and then complete

Select the Created By Me link in the left column of the Web Client. Click the Test3 process link.
The Response value of isComplete is set to true.
The comment is set to ChocoDino order completed by Kwesi.
Figure 58. Result of Test3 execution

Execute several tests including one where the quantityFilled is less than that requested. This order should not be completed.
Close the Web Client. From the Servers view, right-click on the TestServer. Select Stop.
Conclusion
![]() | If you have reached this point in the article you have built two business processes: ProcessChocoDinoOrder and FulfillChocoDinoOrder. The first process used a sequential diagram. The second was implemented with a flow diagram. Both contained the essential BPEL4WS activities. In addition, you used the IBM extensions Staff and Java Snippet. Kwesi is now ready to use your ordering process to help him sell ChocoDino's delicious chocolate dinosaurs. |
-
Developing a custom Web client for Business Process Choreographer with WebSphere Studio Integration Edition. This article show you how to create
a custom Web client using the Business Process Engine (BPE) API. The custom Web client can be used to manage business processes and work items.
- Trial downloads for IBM software products.
No-charge trial downloads for selected IBM DB2, Lotus, Rational, Tivoli, and WebSphere products.
- Most popular WebSphere trial downloads.
No-charge trial downloads for key WebSphere products.
- WebSphere forums.
Product-specific forums where you can ask questions and share your opinions with other WebSphere users.
- developerWorks blogs. Ongoing, free-form columns by software experts, to which you can add
your comments. Check out Grady Booch's blog on Software architecture and engineering.
- developerWorks WebSphere Studio zone.
Access to WebSphere Studio how-to articles, downloads, tutorials, education, product information, and more.
- developerWorks WebSphere Business Integration zone.
Access to WebSphere Business Integration how-to articles, downloads, tutorials, education, product information, and more.








