Adding Conditional Branches to Message Flows

A branch node allows processing to proceed along exactly one of several possible paths. Branching is driven by an XPath-based switch table. Each branch in the table specifies a condition (for example, <500) that is evaluated in order down the message flow against a single XPath expression (for example, ./ns: PurchaseOrder/ns:totalCost on $body). Whichever condition is satisfied first determines which branch is followed. If no branch condition is satisfied, then the default branch is followed. A branch node may have several descendants in the message flow: one for each branch, including the default branch.

If the proxy service is not based on a WSDL and receives multiple document types as input, consider using a conditional branch node.

Conditional branching is driven by a lookup table with each branch tagged with a simple, but unique, string value. A variable in the message context is designated as the lookup variable for that node, and at run time, its value is used to determine which branch to follow. If no branch matches the value of the lookup variable, the default branch is followed. You should design the proxy service in such a way that the value of the lookup variable is set before reaching the branch node.

Before you begin

These instructions assume you are already editing a message flow in the Edit Message Flow page, as explained in Creating, Editing, and Viewing Message Flows.

To add a conditional branch to a message flow

  1. Click a Pipeline Pair Node icon or a Branch Node icon, then click Create Conditional Branch. The conditional branch node is added, and any existing nodes after the inserted branch node are moved to the default branch of the new conditional branch node.
  2. To change the default name and add a description for the branch node, do the following:
    1. Click the  Conditional Branch icon, then click Edit Name and Annotation.
    2. Change the name and description, as desired.
    3. Click Save.
  3. To add branch definitions, click the  Conditional Branch icon, then click Edit Branch. The Edit Branch Node page is displayed.
  4. Do the following:
    1. In the Selected Path field, click Edit to add an XPath expression for specifying the path. See Creating and Editing Inline XQuery and XPath Expressions.
    2. In the Variable field, enter a context variable.
    3. From the Operator field, select a comparison operator.
    4. In the Value field, enter a value for the branch.
    5. In the Label field, enter a label for the branch.
  5. Optionally, under Options:
    • Click Add a New Branch to add a new branch definition to this branch node.
    • Click Delete this Branch to delete a branch definition.
    • Click Move Branch Up or click Move Branch Down to change the positions of branch definitions. This option displays only when more than one branch definition exists.
  6. Click Save to commit the updates in the current session.
  7. On the Edit Message Flow page, continue to construct the message flow, as described in Creating, Editing, and Viewing Message Flows.
  8. Click Save to commit the updates in the current session.
  9. To end the session and deploy the configuration to the run time, click Activate under Change Center.