Lesson 4: Defining error handling for a business process service

In this lesson, you process an invalid sales item by throwing an exception and handling that exception.

  1. Right-click the background of the business process canvas and select Show Tool Palette.

  2. In the Tool Palette, select the Exception Processing category, then drag the Throw Exception activity to the right of the ifInvalid icon on the business process canvas.

  3. Connect the logic. Click the right top arrow (TRUE) of the ifInvalid single-rule activity and drag and click the left arrow of the Exception icon on the canvas.

    NoteThe red “X” on the ifInvalid object disappears when you save the your changes in a later step.

  4. Select the Exception icon on the canvas and expand the Properties pane.

  5. Enter INVALID_SALES_ITEM in the Name and Exception Name field in the Properties pane.

  6. Right-click on the canvas and select Save from the context menu to save the changes.

  7. Restore (minimize) the ValidateSalesItem complex activity, minimize it, right-click the background of the business process canvas, and select Show Tool Palette.

  8. On the Tool Palette, select the Exception Processing category, select the Exception Handler activity, and drag and drop it to the editor canvas.

  9. The Exception Handler displays semi-maximized. Click the Exception Handler minimize icon.

  10. Select the Exception Handler icon on the canvas, expand the Properties pane, and enter HandleInvalidSalesItem in the Name field.

  11. In the Properties pane, click the ellipsis button next to the Exception field to open the Exception Selection Dialog window.

  12. Expand ValidateSalesItem, select INVALID_SALES_ITEM, and click OK.

  13. Select File|Save from the WorkSpace main menu.

  14. In the editor canvas, double-click the HandleInvalidSalesItem activity to expand it, then click its maximize icon to open up the window.

  15. Right-click in the editor canvas and select Show Tool Palette from the context menu. Add two activities:

    1. Select the Activities category and drag the Assign activity onto the canvas to the right of the Start icon on the canvas.

    2. Select the Interface category and drag the Send Response activity onto the canvas to the right of the Assign activity.

  16. Connect the activities:

  17. Select the Assign activity on the canvas, expand the Properties pane, and enter setErrorInfo in the Name field.

  18. Select the SendResponse activity on the canvas and set these values in the Properties pane:

    NoteYou may need to maximize the WorkSpace window to see the arrow for the drop-down lists.

  19. Select the setErrorInfo activity on the canvas. In the Properties pane, click New to add a second Assign in the Assign Overview table.

  20. Set the Assign values in the Assign Overview table in the Properties pane:

  21. Restore and minimize the HandleInvalidSalesItem activity in the editor canvas.

  22. Select File|Save from the WorkSpace main menu.

NoteTo take a break, select File|Close from the WorkSpace main menu to close the editor, and select File|Exit to shut down WorkSpace.

You have finished adding the raising and handling of an exception to a business process service.

The business process service you created has an operation called ManageInventory, which takes a sales item as input and validates the sales item data with a Java service. If the sales item is valid, the operation returns a response indicating success. Otherwise, it returns a response indicating that the sales item is invalid.