You have now completed parts 1 through 4 of this tutorial.
In the Project Explorer view, you should have the following:
Tutorial project
tutorial.bpel
that you created in Part 4
After completing Part 5 of the tutorial, you will be able to:
Use the Outline tab to see your process in a hierarchical view.
Rename a namespace prefix.
Create an If activity.
Create if conditions using the Expression Builder.
Understand the Create Instance attribute for the Receive activity.
Step 1: Use the Outline Tab to Add and Select Building Blocks
The Outline tab (also called a "view"), shown displays all major components of a BPEL process. Here are two Outline views. The one on the left is the default for a new process, containing only the parent nodes. Your outline should look like the one on the right. By starting your process using participants, you have automatically added a namespace, participants, variables, and several activities.
In Outline view, select Correlation Sets.
Click and hold the Correlation Sets node, drag it to the bottom of the outline, and move it slightly until you see a black bar, indicating you can drop it. The loan approval process does not include correlation sets, so you can move this node out of the way.
Tip: You can move items up and down to reorganize them. You can right-mouse click on a node to add new items of the same type.
Step 2: Rename a Namespace Prefix
Each WSDL and schema file declares one or more namespaces that provide a context for messages, port types, and other definitions. The namespaces that are declared in the schema and WSDL files that your process references must also be declared in the process itself.
Because one namespace can have many WSDL files associated with it, Process Developer identifies the WSDL file by using the
Imports
function. The import is automatically added when you create a participant, and a default namespace prefix is also added, which you can rename to make more meaningful.
In Outline view, expand Imports to see the location of the WSDL.
Expand Namespaces and notice the new namespaces. The
loan
prefix and the
loanMessages
prefix are two of the namespaces added.
Process Developer creates namespace prefixes based on WSDL filenames and adds them to the process. The
loanProcess.wsdl
generates the
loan
prefix the
loanRequest.xsd
file and
loanMessages
for
loanMessages.wsdl
file.
Notice the prefixes for all imported WSDLs, which will appear in variable expression that you will create in the process:
WSDL/XSD file from the Namespace URI
| |
Tip: All new processes contain common namespaces. The
xsd
namespace defines the location of the XML schema. The
bpel
namespace defines the location of the BPEL schema. Process Developer adds other namespaces used internally by the process.
Step 3: Adding Programming Logic with an If Activity
The risk assessment determines who is a high risk or low risk, or who needs more review. These conditions will be represented using the If control flow activity.
From the Control Flow drawer of the palette, select a Conditional Pattern activity and drop it just below the invoke activity as shown.
Note that the activity is already structured with If and Else conditional paths. The else condition is indicated with a slash at the beginning of its path.
We need to add an Else If condition. Select the starting diamond of the If, and right mouse-click to select
Add > Other > If Condition
, as shown.
Select the first
If Condition
label and rename it
large loan or review risk
.
Tip: Click once to select the label and then click the text to edit it.
Select the next If Condition label and rename it
low risk
.
Be sure to label the two if conditions in order, left to right. The left-most condition is evaluated first at runtime, as you will see later.
Select the Else label and rename it
high risk
.
Select the Conditional Pattern label and change it to
what is risk level
.
Here is what your process should look like:
Save your file. More errors are reported, which will now be fixed.
Step 4: Create Conditional Expressions
Begin by adding conditional processing for each if condition path.
Double-click the
low risk
If activity (not the label) to open the
If Expression Builder
, as shown.
In the Builder dialog, expand the
riskAssessment
variable and double-click the
riskAssessment
part to add an expression to the If Expression box.
Complete the expression as follows:
$riskAssessment/loan:riskAssessment = 'low'
This is shown in the following example.
For the
large loan or review risk
condition, create an expression for two conditions:
Expand the
creditInformation
message, and double-click the
amountRequested
part.
Complete the expression by adding the large loan amount and the risk assessment review condition, as shown.
$creditInformation/loan:amountRequested >= 10000 or
$riskAssessment/loan:riskAssessment = 'review'
Step 5: Create the Reply for the Low Risk Condition
If the customer requests less than $10,000 and is a low risk, the customer is approved for a loan. Here's how to create a reply with this message.
From the Throw Event drawer of the palette, drag a Message to the blue bounding box of the low risk condition as shown.
Fill in the reply properties in the Properties view as follows:
Activity Name: Approve
Participant: loanProcessor
Operation: request
Select the Data tab of the Properties view.
Note that the Assignment Type is
XPaths
. XPath expressions allow you to select nodes from a variable for assignment. You will now map a literal expression to the reply variable, as follows.
The table structure on this data tab allows for several XPath expressions. We need only one expression. Select Add. (The button is to the right of the table.)
In the
E/L
column, select the f(x) (Expression) entry and change it to (k) Literal expression.
Click in the
From
column and select the Dialog (...) button to open the
Literal Contents
dialog.
Select
Generate
, and in the XML Data Wizard, notice that the matching data type,
loanApprovalResponse
, is selected as the Root Element. The element-based approval message is a single part element.
Select
Finish
. The Literal Contents looks like the following:
Replace the
loan:responseDescription
string with the following:
Your excellent credit has earned you automatic approval for your loan
.
Delete the entire
<loan:rejectionReason> </loan:rejectionReason>
element. The literal expression will be:
<loan:loanApprovalResponse xmlns:loan=
"http://schemas.active-endpoints.com/sample/LoanRequest/
2008/02/loanRequest.xsd">
<loan:responseToLoanRequest>approved
</loan:responseToLoanRequest>
<loan:responseDescription>Your excellent credit has earned you automatic
approval for your loan.
</loan:responseDescription>
</loan:loanApprovalResponse>
The Data tab should look like the following.
Step 6: Create the Reply for the High Risk Condition
The reply for the high risk customer is created with almost identical steps used for the low risk customer. You can use a shortcut and make a copy of the approve reply to create the deny reply.
Copy the Approve reply and paste it into a blank area of the canvas. The reply is pasted into the top-left corner.
In the Properties view, rename the Activity Name to
Deny
. The Participant and Operation are already filled in.
In the Data tab, select in the
From
cell to display a dialog (...) button, and then select it.
Select Generate, then Finish.
Edit the literal contents for the denied loan. The message should read as follows:
<loan:loanApprovalResponse xmlns:loan=
"http://schemas.active-endpoints.com/sample/LoanRequest/
2008/02/loanRequest.xsd">
<loan:responseToLoanRequest>
declined
</loan:responseToLoanRequest>
<loan:responseDescription>We are sorry, this application
falls outside of our credit risk guidelines.
</loan:responseDescription>
<loan:rejectionReason>
<loan:reason>lowCredit</loan:reason>
<loan:description>low credit score
</loan:description>
</loan:rejectionReason>
</loan:loanApprovalResponse>
Drag the Deny reply to the bounding box in the high risk condition. Your process should now look like the following.
Step 7: Create the Invoke Loan Approver Activity
You have one more path to complete for the If activity: the case where the loan request is large or the customer's risk level could not be determined by the risk assessment service.
Recall that you have already created two partner services for the process and are already using the risk assessment service via the risk assessment invoke activity. Now you will use the loan approval service.
In the Participants view expand Partner Service Providers to view the LoanApproval partner.
Expand LoanApproval to view the approve operation.
Drag the approve operation to the bounding box of the large loan or review risk condition. A new invoke activity is created, as shown.
In the Properties view, name the activity
Invoke Loan Approval
.
Select Green for the activity color.
On the Input tab, in Assignment Type, select Single Variable.
For the Variable, select
creditInformation
.
On the Output tab, in Assignment Type, select Single Variable.
For the Variable, select
approval
.
Step 8: Add the Loan Approval Reply
Select the Return Approval Response reply and drag it into the bounding box containing the new invoke activity. Be sure to move the activity very close to the bottom of the invoke activity to place it in sequence inside the bounding box.
Notice that the process now has three discrete end activities, clarifying the process flow.
Your completed process definition should look like the following.
Step 9: View the Create Instance property for the Receive activity
The Receive is the activity that kicks off the process, so you want to ensure that the Create Instance property is enabled. Process Developer automatically adds the Create Instance property to the Receive (or other start) activity that you add to the process.
In the Process Editor, select the Receive activity.
In the Properties view, notice that a checkmark was added to the Create Instance box.
Step 10: Save Your File and Validate Your Process
Save your file. When you save it, it is automatically validated for BPEL.
View Problems view, stacked next to Properties view. There should be no errors listed.
If any errors are listed, double-click the error to go to the source of the error.
Tip: You can compare your file to
tutorialCompleted.bpel
to discover any differences. To open a completed version of the tutorial, select File > New > Orchestration Project, name the project, click
Next
, and then select the Template
Tutorial Completed
.
Note that the
tutorialCompleted.bpel
file has one difference: The sequence surrounding the process was removed by using the Ungroup right-mouse menu option.
You have completed the main process definition.