Setting Up Exception and Default Handlers in a Business Process

Use the following example to set up an exception handler in a business process that throws a specific exception.

Example Exception and Default Handlers in a Business Process

The request operation sends data to an assign activity. The assign sends the data to a complex activity named Specific
that contains a single-rule. The hit node of the single-rule throws a specific exception which is handled by a Specific
Handler. The no-hit node of the single-rule throws a general exception which is handled by a Default Handler.

To set up exception and default handlers in a business process:

  1. Create a business process service.

  2. Define input and output parameters for the service operation:

    1. Select the Service Interface tab in the Business Process service editor.

    2. Select the operation on the service interface.

    3. Expand the Operation Parameters section and add the following parameters:

    4. Service Operation Parameter Properties

      NameStyleDatatype

      input

      Input

      Simple/string

      output

      Output

      Simple/string

    5. Save the service. Select File|Save from the main menu bar.

  3. Add an Assign activity to the business process:

    1. Click the Business Process tab.

    2. Click inside the Business Process canvas and then select the Tool Palette using the Fast View shortcut bar.

    3. Select Assign from the Activities palette and drag it on to the canvas.

    4. Define the source and target for the Assign:

      1. Select the Assign activity.

      2. Drag the input parameter from the Interface Variables category in the Business Process Variables section into the Source column in the Properties panel.

      3. Drag the output parameter from the Interface Variables category in the Business Process Variables section into the Target column in the Properties panel.

    5. Save the service. Select File|Save from the main menu bar.

  4. Add a complex activity to the business process service:

    1. Click inside the Business Process canvas and then select the Tool Palette using the Fast View shortcut bar.

    2. Select Complex from the Activities palette and drag it on to the canvas.

    3. Select the complex activity on the canvas and rename from Complex to Specific in the Properties panel.

    4. Maximize the Specific activity to increase your work space.

    5. Save the service. Select File|Save from the main menu bar.

    6. Add single-rule logic to the complex activity.

      See Expression Editor for more information.

      1. Click inside the Business Process canvas and then select the Tool Palette using the Fast View shortcut bar.

      2. Select Single-rule from the Logic palette and drag it on to the canvas.

      3. Define the single rule using the following example:

        Example single-rule expression: An input parameter is equal to a string constant called specific.

        1. Select the single-rule on the design canvas.

        2. Expand the Properties view.

        3. Replace the Select Variable in the Expression editor. Drag input from the Interface Variables list in the Business Process Variables section onto the Select Variable.

        4. Select the string constant in the Expression editor and rename it in the Properties for the Operation view to specific. Then, select the Bind Source Text to Logical Name checkbox.

        5. Save the service. Select File|Save from the main menu bar.

    7. Add two Throw Exceptions to the Specific activity:

      1. Select Throw Exception from the Exception Processing tool palette and drag it into Specific. Do this action twice.

      2. Select the first Throw Exception on the canvas and rename its Name and Exception Name to Specific Exception in the Properties panel.

      3. Select the second Throw Exception on the canvas and rename its Name and Exception Name to Exception in the Properties panel.

      4. Connect the Start to the Single-rule and the Hit node of the Single-rule to the Specific Exception and then connect the No-Hit node to the Exception.

      5. Minimize the Specific activity to return to the core business process.

      6. Save the service. Select File|Save from the main menu bar.

  5. Add a Default Handler to the business process:

    1. Maximize the Default Handler handler to increase your work space.

    2. Add an assign activity to the Default Handler:

      1. Click inside the Business Process canvas and then select the Tool Palette using the Fast View shortcut bar.

      2. Select Assign from the Activities palette and drag it on to the canvas.

      3. Define the source and target for the Assign:

        1. Select the Assign activity.

        2. In the Properties panel, click in Source column and then click the ellipsis button to open the Variable Reference dialog.

        3. Select Literal, type from the default handler in the text box, and click OK.

        4. Drag the output parameter from the Interface Variables category in the Business Process Variables section into the Target column in the Properties panel.

      4. Save the service. Select File|Save from the main menu bar.

    3. Add a Send Response interface to the Default Handler:

      1. Select Send Response from the Interface palette and drag it on to the canvas.

      2. Define the operation. In the Properties panel, select BPService:operation1 from the Operations drop-down list.

    4. Connect the Start and the Assign and the Assign to the Send activities.

    5. Save the service. Select File|Save from the main menu bar.

    6. Minimize the Default Handler to return to the core business process.

  6. Add an Exception Handler to the business process:

    1. Drag the Exception Handler from the tool palette onto the business process canvas.

    2. Select the Exception Handler icon on the canvas and rename it to Specific Handler in the Properties panel.

    3. Maximize the Specific Handler to increase your work space.

    4. In the Properties panel, click the ellipsis button to the right of the Exception field to open the Exception Selection dialog.

    5. Select Specific|Specific Exception and click OK.

    6. Save the service. Select File|Save from the main menu bar.

    7. Add an Assign activity to the Specific Handler:

      1. Click inside the Exception Handler canvas and then select the Tool Palette using the Fast View shortcut bar.

      2. Select Assign from the Activities palette and drag it onto the exception handler canvas.

      3. Define the source and target for the Assign:

        1. Click the ellipsis button in Source column in the Properties panel to open the Variable Reference dialog.

        2. Select Literal, type from the specific exception handler in the text box, and click OK.

        3. Drag the output parameter from the Interface Variables category in the Business Process Variables section into the Target column in the Properties panel.

      4. Save the service. Select File|Save from the main menu bar.

    8. Add a Send Response interface to the business process:

      1. Select Send Response from the Interface palette and drag it on to the canvas.

      2. Define the operation. In the Properties panel, select BPService:operation1 from the Operations drop-down list.

    9. Connect the Start to Assign and Assign to Send Response.

    10. Save the service. Select File|Save from the main menu bar.

    11. Minimize the Specific Handler twice to return to the core business process.

  7. Connect the flow of execution, using the example graphic at the introduction of this topic.

  8. Save the service. Select File|Save from the main menu bar.

    When the business process is invoked, an input of "specific" executes the Specific Exception. The return is the literal "from the specific handler." Any other input executes the default handler and returns the literal "from the default handler."

Handlers

Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com