Core elements, constructs, and components of Flow services

Use the core elements, constructs, and components that are needed to create and run a flow service.

On the new flow service page, click the rectangular box. By default, the left page lists the recently used Connectors, Controls, Project services, and Built-in services.

You can type a keyword in the rectangular box and search for the available elements. IBM webMethods Integration filters the data based on what you type in the search box.

Click All to view the categories available on the right page, which you can use to build the flow service.

Categories

Displays the following categories -

  • Connectors
  • Controls
  • Project Services
  • Package Services
  • Built-in Services

Connectors

Displays the connectors available to create the Flow service.

Connectors are grouped in the following categories on the flow services page.

Predefined Connectors

Predefined and configurable connectors. These connectors establish connections to SaaS providers.

Note: A few connectors are deprecated in this release. A deprecated connector displays the Deprecated label where ever it appears in the user interface. IBM fully supports deprecated connectors, which continue to work as before. If you are using deprecated connectors in your existing Workflows or flow services, they work as expected. No new feature enhancements are made for deprecated connectors. If you are creating new Workflows or flow services, use the provided alternative connectors instead of the deprecated connectors. The deprecation is applicable only for Actions. The deprecation is not applicable for Triggers, that is, Triggers are supported for both deprecated and alternative connectors. For the list of triggers, see the documentation for alternative connectors.

REST Connectors

You can define REST Resources and Methods and create custom REST connectors. You can start a REST API in a flow service by using a REST connector.

SOAP Connectors

Displays custom SOAP connectors. Custom SOAP connectors provide access to third-party web services that are hosted in the cloud or on-premises. A SOAP API can also be started in a flow service that uses a SOAP connector. You can also start a SOAP API in a flow service by using a SOAP connector.

On-Premises Connectors

On-Premises applications uploaded from on-premises systems.

Flat File Connectors

Displays the Flat File connectors created either manually or from a sample file.

Controls

A flow service uses Controls as programming constructs to run a specified sequence based on a field value, try a set of steps, and catch and handle failures. The page shows conditional expressions, looping structures, and the transform pipeline. Conditional expression runs different computations or action that is depending on whether a specified Boolean condition evaluates to true or false.

Sequence

Use the Sequence step to build a set of steps that you want to treat as a group. Steps in a group are run in order, one after another.

Conditional Controls

  • If - Use the If statement to return one value if a condition is true and another value if it's false.
  • If Else- Use the If statement to return one value if a condition is true and another value if it's false. Else runs if the result of a previous test condition evaluates to false.
  • Else If- The If step is used to evaluate a Boolean condition and if the condition is true, statements inside the If step are run. The If step can be followed by an else step, which runs when the Boolean expression is false. The If statement runs in sequential order. You can use one If or Else If Statement inside another If or Else..If..Statements.
  • Nested Condition - Nested conditions comprise condition statements that are contained within other condition statements. Conditions consisting of multiple statements are connected by using the logical AND and OR operators.

Loops

Loops repeat a set of steps multiple times based on the selected block. It repeats a sequence of child steps once for each element in an array that you specify. For example, if your pipeline contains an array of purchase-order line items, you might use a Loop to process each line item in the array. Loop requires you to specify an input array that contains the individual elements that are used as input to one or more steps in the Loop. At run time, the Loop runs one pass of the loop for each member in the specified array. For example, to run a Loop for each line item in a purchase order, use the document list that stores the order’s line items as the Loop’s input array.

A Loop takes an array field from the pipeline as input. It iterates over array members, running its child steps each cycle. For a flow service with a string input and string list, use Loops to run the service once per string.

. You identify a single array field to use as input when you set the properties for the Loop. You can also designate a single field for the output. The loop collects an output value each time it runs through the loop and creates an output array that contains the collected output values.

  • Repeat
    • Repeat- The repeat step iterates only on an array and the number of executions is equal to the size of the array.
    • Repeat for Count- Repeat for Count specifies the maximum number of times IBM webMethods Integration re-runs the child steps in the Repeat step. If the count is set to 0, the Repeat step does not re-run the child steps. If the count is set to any value > 0, the Repeat step re-runs the child steps up to this number of times. Children of a Repeat step always run at least once. The count property specifies the maximum number of times the children can be re-run. The concept is the same as Repeat for each. The only difference here is that you iterate for a specific count. It can be specified directly on a step or through a variable (I/O or Pipeline).
    • Repeat for input/output- The concept is the same as Repeat for each. The only difference here is that you can iterate on two different arrays concurrently.
  • While- While loop is used to iterate a part of the program several times. If the numbers of iterations are not fixed, use the While loop.
  • Do Until- Do Until loops are similar, except that they repeat their bodies until some condition is false.
  • Break- Use the Break step only within a loop. It stops execution within the containing loop and exits. In nested loops, the Break step exits the inner loop first before moving to the outer loops. Child steps cannot be attached to the Break step.
Note: An infinite loop triggers a default timeout that is configured in IBM webMethods Integration. If the time taken for execution exceeds this limit, the flow service execution is terminated. Contact your administrator for to customize the default timeout.

Example - Loop through nested arrays in flow services

Given the following nested document structure in JSON, retrieve the node6 element and apply an if condition to it.

JSON Nested Structure


{
  "node1": {
    "node2": {
      "node3": [
        {
          "node4": {
            "node5": [
              {
                "node6": "Hello"
              }
            ]
          }
        }
      ]
    }
  }
}
  1. In Flow Editor, define the data fields in the input/output signature.

    For more information on defining input and output fields, see Input and Output Fields Declaration

  2. In the flow step, add a Repeat for node3.

  3. Inside the node3 loop, add another Repeat for node5.

  4. Add the IF condition, and select node6. Hover over the node to confirm its full path when duplicate node names exist.

Error Handling

  • Try, Catch, Finally- You can use these steps to try a sequence of flow service steps, catch and handle any failures that occur, and then run any cleanup work. When adding the Try, Catch, and Finally steps to a flow service, decide which usage pattern you want to use. This can be a Try-Catch, a Try-Finally, or a Try-Catch-Finally. Identify the logic for which you want to provide exception handling. The steps for this logic belong in the Try step. Then decide whether you want to handle exceptions and if so, which ones. Catch steps can handle all exceptions or specific exceptions. If the service handles exceptions, what recovery logic or logging needs to be added? Lastly, identify any cleanup logic that you want the service to run, that is, decide whether you need to include a Finally step. The general usage pattern for try-catch-finally is a single Try step followed by zero or more Catch steps, followed by zero or one Finally step. Catch steps can be configured to handle specific failures. The Finally step runs a set of steps after a Try step completes successfully or fails. If a Catch step runs, IBM webMethods Integration runs the Finally step after the Catch step completes. The Try-Catch usage pattern consists of a single Try step followed by one or more Catch steps. The Try step contains any number of child steps to be run. The Catch step contains any number of child steps to be run if the Try step fails. The Try-Finally usage pattern consists of a single Try step followed by a Finally step. The Try step contains any number of child steps to be run. The Finally step contains any number of child steps to run regardless of the outcome of the Try step. The Try-Finally usage pattern does not handle any failures that occur in the Try step. As a result, any failure from the Try step remains to pend. After the Finally step completes, IBM webMethods Integration propagates the failure to the parent flow step of the Try step if the Finally step completes normally. The Try-Catch-Finally usage pattern is a combination of Try-Catch and Try-Finally. A Try-Catch-Finally consists of a Try step that contains logic to be attempted, followed by one or more Catch steps to handle any failure that occurs and run recovery logic. This is followed by a single Finally step to perform any clean up. The Finally step contains logic that is run regardless of whether the Try step succeeds or fails. Often, the Finally step contains clean up logic that needs to run regardless of the outcome of the preceding Try or Catch steps.
  • Throw Error- You can attach the throwerror step inside any step except the catch section of the try catch step. You can explicitly throw an exception with a custom error message. If you use this step inside the try section of the try catch step, the error is caught in the catch section. If you use the value of a pipeline variable for this custom error message, type the variable name between % symbols, for example, %mymessage%. The variable that you specify must be a String. You cannot attach child steps to the Throwerror step. If you add a Throwerror step inside a try catch step, any changes that are done to the pipeline variables inside the try step are reset to the previous values existing in the pipeline.

Exit

This step exits the entire flow service and signals success or failure as part of the exit.

  • Exit Flow service signaling success step allows you to successfully terminate and exit from the currently running flow service. You cannot attach child blocks to the Exit flow service signaling the success step.
  • Exit Flow service signaling failure step abnormally terminates the currently running flow service with a failure message. You can specify the text of the failure message that is to be displayed. If you want to use the value of a pipeline variable for this flow service message, type the variable name between % symbols, for example, %mymessage%. The variable that you specify must be a String. You cannot attach child steps to the Exit flow service signaling failure step.

Switch Case

Switch allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being turned on is checked for each case, that is, Switch evaluates a variable and skips to the value that matches the case. For example, if the Switch variable evaluates as A, then case A is run. A switch statement can have an optional default case, which must appear at the end of the switch. The default case runs a task when none of the cases are true. You cannot insert multiple default statements. You can include case steps that match null or empty switch values. A switch value is considered to be null if the variable does not exist in the pipeline or is explicitly set to null. A switch value is considered to be an empty string if the variable exists in the pipeline but its value is a zero length string. Switch runs the first case that matches the value, and exits the block.

Branch

A branch is a conditional execution of steps and constitutes a group of expressions. Within a Branch, IBM webMethods Integration runs the first expression that evaluates to true. Expressions are the conditions on the pipeline variables.

At run time, the Branch evaluates the conditions that are provided and runs the first expression whose condition is evaluated to true. If none of the expressions are true, the default expression if included, is run.

If you want to perform different actions on different values of one or more pipeline variables, use the Branch construct. In the following example, action is a pipeline variable created that uses the Define input and output fields dialog box.

The Branch contains two conditional expressions and a default expression.

Scenario 1

If the value of the action starts with mult, IBM webMethods Integration evaluates the first expression (action = /^mult/) and runs step 3, that is, performs the multiplication operation.

Scenario 2

If the value of the action is addition (action == "addition"), then the Branch starts its execution from step 2. As step 2 is evaluated to false, the execution moves to the next expression, that is, step 4. Step 4 is evaluated to true, hence step 5 is run, that is, the addition operation is performed. Remaining expressions in the Branch, if any, are ignored and the execution falls through to the next step after the Branch in the flow service.

Scenario 3

Let us assume that the value of action is subtraction. The Branch then starts its execution from step 2. As IBM webMethods Integration evaluates step 2 to false, the execution moves to the next expression, that is, step 4. IBM webMethods Integration evaluates Step 4 to false, hence evaluates step 6 ($default), that is, runs step 7, which makes the execution exit the flow service.

Note:
  • If you are specifying a field in a document or in a document reference, format it as document/documentVariable. For example, if you want to specify a field name, from the document employeeProfile, then format it as employeeProfile/name.
  • If you specify a literal value in an expression, the value you specify must exactly match the run-time value of the pipeline variable. Further, the value must be case-sensitive.
  • IBM webMethods Integration runs only the first target step whose expression evaluates to true. If none of the expressions evaluate to true, none of the child steps are started, and the execution falls through to the next step in the flow service, if there is no default expression.
  • If you want to prevent the execution from falling through a Branch step when an unmatched value occurs at run time, include a default target step to handle unmatched cases. Branch can have zero to many default expressions. IBM webMethods Integration runs the first sequentially encountered default expression.
  • The default step does not need to be the last step of a Branch but IBM webMethods Integration always evaluates the default step at the end.

Any step other than an expression cannot be a direct child of a Branch step. Further, you cannot add the expression step anywhere outside a Branch. If you are branching on expressions, make sure that the expressions you assign to the target steps are mutually exclusive. In addition, do not use null or empty values when branching on expressions. IBM webMethods Integration ignores such expressions and does not display any errors. You can provide multiple conditions for each expression and can also use regular expressions, for example, /^mult/. The expressions that you create can also specify a range of values for the variables.

Specify the value of the variables in the expressions, as mentioned in the following table-

To Match... Specify...
That exact string A string
The string representation of the object’s value. Example for Boolean object- true Example for Integer object- 123 A constrained object value
Any string matching the criteria specified by the regular expression. Example- /^REL/ A regular expression
An empty string A blank field
A null value $null
Any unmatched value (that is, run the step if the value does not match any other label) $default

Transform Pipeline

As systems rarely produce data in the exact format that the other systems need, at times you need to transform data in terms of format, structure, or values of data. Using the Transform Pipeline control in the flow service you can do transformations on data in the Pipeline. You can insert multiple transformers in a single Transform Pipeline step to run multiple data transformations.

When multiple transformers are added, the Transform Pipeline step behavior is as follows-

  • All transformers are contained within a Transform Pipeline step and do not appear as a separate flow service step in the editor.

  • All transformers are independent of each other and do not run in a specific order.

Therefore, the output of one transformer cannot be used as the input to another transform. These characteristics make the Transform Pipeline step different than that of a normal step in a flow service.

Inserting a Transform Pipeline Step in a Flow service

  1. Create a flow service. A flow service step is created initially without any data.

  2. Select Transform Pipeline from the step drop-down list. The Transform Pipeline step is added.

Adding Transformers

  1. Create a flow service. A flow service step is created initially without any data.

  2. Select Transform Pipeline from the step drop-down list.

  3. Click on the flow service step. The Pipeline page appears.

  4. Click on the Transformers column header. The Select Transformer step is added under the Transformers column.

  5. Select the function from Select Transformer. The input field values are modified based on the selected transformer.

Mapping Pipeline Fields to Transformer Fields

The pipeline fields can be mapped to the service fields of the transformers added.

  1. Go to the Transformer step (for which the transformers have been added) in the Pipeline page.
  2. Click in the Transformer step. The fields are displayed.
  3. Link the fields as per your requirements.
Note:
  • At a time, only one transformer can be expanded. On collapsing, all the existing transformers are visible.
  • You can delete a transformer that uses the delete icon against each transformer. If a transformer is deleted, the mappings to its service fields are also deleted.

Mapping Fields Directly

The Pipeline Input fields can be directly mapped to any of the Pipeline Output fields. This is known as Direct Mapping.

Example

Let’s see how transformers work with the help of an example. In the following example, we transform the case of a string field label to uppercase.

  1. Provide a name and description of the new flow service and click the Input/output icon.
  2. Define an input field Currency Code and click Done.
  3. Select Transform Pipeline.
  4. Click the pipeline-mapping icon and open the pipeline-mapping window.
  5. On the pipeline-mapping window, click the Add New Transformer option.
  6. The Select Transformer page appears.
  7. Click ALL on the transformer page.
Note:
  • Specify the pipeline input and output variables in the corresponding flow when starting a flow service in the transform step to make sure visibility of the signature.
  • You cannot use the Controls category within a flow service transform step.

7.Select the toupper service.

8.Click the Expand icon.

9.Map Currency Code to inString and value to Currency Code.

10.Save the flow service and run it. In the Input values dialog box, type usd as the Currency Code.

11.Click Run on the Input values dialog box. The transformer converts the string field usd in lowercase to uppercase.

Note: You can delete a transformer by clicking the delete icon against each transformer. If a transformer is deleted, the mappings made to the service variables are also deleted.

Project Services

Displays the flow services available in the selected project. This enables you to invoke other flow services from the current flow service. The input and output of the referred flow service must be accordingly mapped for a successful execution.

Built-in Services

Displays the service categories. An extensive library of built-in services is available for performing common tasks such as transforming data values, performing simple mathematical operations, and so on.

Service input and output parameters are the names and types of fields that the service requires as input and generates as output and these parameters are collectively referred to as a signature.

Note: Related services are grouped in categories. See Built-in Services for information on the service categories, and input parameters, output parameters, and usage notes if any for each service.