In this lesson, you process an invalid sales item by throwing an exception and handling that exception.
Right-click the background of the business process canvas and select Show Tool Palette.
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.
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.
The red “X” on the ifInvalid object
disappears when you save the your changes in a later step.
Select the Exception icon on the canvas and expand the Properties pane.
Enter INVALID_SALES_ITEM in the Name and Exception
Name field in the Properties pane.
Right-click on the canvas and select Save from the context menu to save the changes.
Restore (minimize) the ValidateSalesItem complex activity, minimize it, right-click the background of the business process canvas, and select Show Tool Palette.
On the Tool Palette, select the Exception Processing category, select the Exception Handler activity, and drag and drop it to the editor canvas.
The Exception Handler displays semi-maximized. Click the Exception Handler minimize icon.
Select the Exception Handler icon
on the canvas, expand the Properties pane,
and enter HandleInvalidSalesItem
in
the Name field.
In the Properties pane, click the ellipsis button next to the Exception field to open the Exception Selection Dialog window.
Expand ValidateSalesItem,
select INVALID_SALES_ITEM
,
and click OK.
Select File|Save from the WorkSpace main menu.
In the editor canvas, double-click the HandleInvalidSalesItem activity to expand it, then click its maximize icon to open up the window.
Right-click in the editor canvas and select Show Tool Palette from the context menu. Add two activities:
Select the Activities category and drag the Assign activity onto the canvas to the right of the Start icon on the canvas.
Select the Interface category and drag the Send Response activity onto the canvas to the right of the Assign activity.
Connect the activities:
Click the right arrow on the Start activity and drag it to and click the input arrow on the left of the Assign activity.
Click the output arrow on the right of the Assign activity and drag it to and click the input arrow on the left of the Send Response activity.
Select the Assign activity
on the canvas, expand the Properties pane,
and enter setErrorInfo
in the Name field.
Select the SendResponse activity on the canvas and set these values in the Properties pane:
Name – enter ManageInventoryResponse
.
Operation – select MySalesBPService:ManageInventory
from
the drop-down list.
Response Variable – verify that NormalResponse
is
selected from the drop-down list.
You may need to maximize the WorkSpace window to see
the arrow for the drop-down lists.
Select the setErrorInfo activity on the canvas. In the Properties pane, click New to add a second Assign in the Assign Overview table.
Set the Assign values in the Assign Overview table in the Properties pane:
First Assign – click the ellipsis
button in the Source column, select Literal,
enter FAILURE
in the Variable
Reference Dialog, and click OK.
Click the ellipsis button in the Target column,
select Interface Variables/MySalesBPService/MySalesBPService/ManageInventory/outputResponse/SalesDetailResponse/sequence/ProcessingResult
,
and click OK.
Second Assign – click the ellipsis button
in the Source column, select Literal,
enter INVALID SALES ITEM
in
the Variable Reference Dialog, and
click OK.
Click the ellipsis button in the Target column,
select Interface Variables/MySalesBPService/MySalesBPService/ManageInventory/outputResponse/SalesDetailResponse/sequence/FailureReason
,
and click OK.
Restore and minimize the HandleInvalidSalesItem activity in the editor canvas.
Select File|Save from the WorkSpace main menu.
To 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.