Getting Started

Getting Started

Part 5: Adding Process Activities and Properties

Part 5: Adding Process Activities and Properties

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.
Outline view default view
Outline view with items added view the operation wizard
  1. In Outline view, select Correlation Sets.
  2. 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.
    Drag and drop outline node
    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.
  1. In Outline view, expand Imports to see the location of the WSDL.
    Imports node of Outline view displaying WSDL location and namespace
  2. 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.
  3. 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
    Prefix
    loanRequest.xsd
    loan
    loanMessages.wsdl
    loanMessages
    loanProcess.wsdl
    loanProcess
    riskAssessment.wsdl
    riskAssessment
    loanApproval.wsdl
    loanApproval
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.
  1. From the Control Flow drawer of the palette, select a Conditional Pattern activity and drop it just below the invoke activity as shown.
    if activity
    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.
  2. 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.
    add other if condition
  3. 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.
  4. 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.
  5. Select the Else label and rename it
    high risk
    .
  6. Select the Conditional Pattern label and change it to
    what is risk level
    .
    Here is what your process should look like:
    If Expression Builder dialog
  7. 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.
  1. Double-click the
    low risk
    If activity (not the label) to open the
    If Expression Builder
    , as shown.
  2. In the Builder dialog, expand the
    riskAssessment
    variable and double-click the
    riskAssessment
    part to add an expression to the If Expression box.
  3. Complete the expression as follows:
    $riskAssessment/loan:riskAssessment = 'low'
    This is shown in the following example.
    If Expression Builder dialog
  4. For the
    large loan or review risk
    condition, create an expression for two conditions:
    1. Expand the
      creditInformation
      message, and double-click the
      amountRequested
      part.
    2. 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'
      If Expression Builder dialog
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.
  1. From the Throw Event drawer of the palette, drag a Message to the blue bounding box of the low risk condition as shown.
    add reply to if condition
  2. Fill in the reply properties in the Properties view as follows:
    1. Activity Name: Approve
    2. Participant: loanProcessor
    3. Operation: request
  3. Select the Data tab of the Properties view.
  4. 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.
    1. 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.)
    2. In the
      E/L
      column, select the f(x) (Expression) entry and change it to (k) Literal expression.
    3. Click in the
      From
      column and select the Dialog (...) button to open the
      Literal Contents
      dialog.
    4. 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.
    5. Select
      Finish
      . The Literal Contents looks like the following:
      literal contents
    6. Replace the
      loan:responseDescription
      string with the following:
      Your excellent credit has earned you automatic approval for your loan
      .
    7. 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.
    data tab of reply
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.
  1. Copy the Approve reply and paste it into a blank area of the canvas. The reply is pasted into the top-left corner.
  2. In the Properties view, rename the Activity Name to
    Deny
    . The Participant and Operation are already filled in.
  3. In the Data tab, select in the
    From
    cell to display a dialog (...) button, and then select it.
  4. Select Generate, then Finish.
  5. 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>
  6. Drag the Deny reply to the bounding box in the high risk condition. Your process should now look like the following.
    Approve and Deny replies
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.
  1. In the Participants view expand Partner Service Providers to view the LoanApproval partner.
  2. Expand LoanApproval to view the approve operation.
  3. Drag the approve operation to the bounding box of the large loan or review risk condition. A new invoke activity is created, as shown.
    Approve and Deny replies
  4. In the Properties view, name the activity
    Invoke Loan Approval
    .
  5. Select Green for the activity color.
  6. On the Input tab, in Assignment Type, select Single Variable.
  7. For the Variable, select
    creditInformation
    .
  8. On the Output tab, in Assignment Type, select Single Variable.
  9. 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.
complete process
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.
  1. In the Process Editor, select the Receive activity.
  2. In the Properties view, notice that a checkmark was added to the Create Instance box.
Step 10: Save Your File and Validate Your Process
  1. Save your file. When you save it, it is automatically validated for BPEL.
  2. 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.

0 COMMENTS

We’d like to hear from you!