Getting Started

Getting Started

Part 6: Adding Fault Handling

Part 6: Adding Fault Handling

To start at the beginning of the tutorial, see 1: Starting a New Process.
Fault handling in a BPEL process is reverse work, undoing the partial and unsuccessful work of a scope in which a fault has occurred. When a fault occurs, normal processing is terminated, and control is transferred to the associated fault handler.
So far in the tutorial, you have completed a BPEL process definition that contains all the steps for normal processing. Now you will add a fault handler to handle a service invocation fault.
If the loan process throws a fault, it terminates the process using a standard fault, and turns over control to the fault handler activity.
In the
loanprocess.wsdl
file, there is a fault name and a fault message defined for the WSDL's operation, namely the request operation. The loan process uses the fault name and message in defining fault handling activities for the assessor and approver services.
In the Project Explorer view, you should have the following files:
  • tutorial.bpel
    that you created in Part 2
  • tutorialCompleted.bpel
    , which is a completed version of the file (optional)
After completing Part 6 of the tutorial, you will be able to:
  • Add a Catch fault handler for the process.
  • Add a fault variable.
  • Add a fault handling activity to the Catch handler.
Step 1: Add a Catch Fault Handler and Fault Variable
When a fault handler receives an inbound fault message, it assigns the fault message to a variable before proceeding to perform an activity enclosed by the catch.
  1. Click on the Fault Handlers tab of the Process Editor.
  2. From the Catch Event palette, drag an Error activity to the canvas.
  3. Select the activity.
  4. In the Properties view, select Fault Variable Definition, and click the dialog (
    ...
    ) button at the end of the row.
  5. Fill in the
    Fault Variable Definition
    dialog as follows and click OK:
    1. Select the Element radio button.
    2. From the list of messages, select
      loan:errorMessage
      .
      Fault Variable Definition Dialog
  6. In the Properties view, select Fault Name, and click the dialog (
    ...
    ) button at the end of the row.
  7. In the Fault Name list, notice that the WSDL fault name associated with both the assessor and approver services is the same, but each is in a different namespace. For convenience, the WSDL for each service used the same fault name, but usually if you are orchestrating two different services the fault names would be different. Select the
    loanApproval:loanProcessFault
    , as shown in the example.
    approver's LoanProcess Fault
  8. In the Fault Variable field, type
    errorApprove
    , which is the name we will associate with the fault variable definition. The properties for the Catch activity should look like the following example:
    Properties for error variable in Catch activity
Notice that a new variable named
errorApprove
was to Process Variables view. This variable is exclusively for fault handling, and this is shown using an icon that differs from normal process variables.
process variables view with fault variable
Step 2: Add a Fault Handling Activity
When a fault is caught, the fault handler must execute an activity. You will add a Reply activity to tell the customer that the process was unable to handle the request.
  1. From the Throw Event palette, drag a Message activity into the Catch handler and name the activity
    ReplywithApprovalFault
    , as shown.
    Reply activity in catch handler
  2. Fill in the properties for the reply activity to handle the fault, as shown in the example. You must select them in the following order:
    1. Participant (loanProcessor)
    2. Operation (request)
    3. Fault Name (unableToHandleRequest)
    Reply activity properties, inlcuding Fault Name
  3. On the Data tab, select the new variable (
    errorApprove
    ).
    Reply activity properties, inlcuding Fault Name
  4. Add a similar Fault handler for the risk assessment service by selecting the same fault variable definition and the new fault name
    riskAssessment:loanProcessFault
    and naming the fault variable
    errorRisk
    . Name the Reply
    ReplywithRiskFault
    .
Your Fault Handlers view should be similar to the following:
fault handlers complete

0 COMMENTS

We’d like to hear from you!