webMethods Flow Tutorial - No.2 Create and Run a Flow Service

Duration:  30 minutes 

Flow is a simple, point-and-click programming language, optimized for coding services. In this tutorial you will create and execute a Flow service that will perform some simple operations.

Prerequisites #

This tutorial builds on concepts, techniques, and objects that were covered in the previous tutorial.

Step Outline #

You create and run a Flow service by:

  • Creating the Flow service object
  • Adding inputs and processing steps to the service
  • Verifying the output from the service

Step 1: Create a Flow Service #

In this step: You will create a Flow service by defining the Flow service object in the services folder of the FLOW_Tutorial package.

To create a Flow service:

  • locate the FLOW_Tutorial package that you created previously, and expand the folder hierarchy:

  • Right-click on the services folder in the FLOW_Tutorial package, then select New -> Flow Service:

The New menu displays all the types of objects you can create on the IS.

In the New Flow Service dialog, enter customWriteToLog in the Element name field and select Finish:

Designer creates the new flow service and opens it up in the Flow editor. Expand the services folder to see your newly created flow service:

By default, the Tree tab is selected, showing an empty Flow. The Flow Palette may be expanded by clicking on the arrow on the right side of the flow editor:

  • Click the Input/Output tab on the bottom of the Flow Editor to open:

You may now add inputs to the new service. Open the Variables Palette by clicking the open arrow on the right of the Input/Output editor.

Step 2: Add String Inputs to the Service #

In this step: You will add string inputs to the service using the Input/Output tab. When you run the service, the value of the input strings will be operated on and displayed as results.

To add a string input to the service:

  • Option 1 (click-and-click): Click once on String, and then click again in the white space in the left (input) panel, below the Validate Input checkbox:

  • Option 2 (click-and-drag): Select String then drag it to the white space in the left (input) panel, below the Validate Input checkbox:

  • Option 3 (right click): right-click in the white space in the left (input) panel, below the Validate Input checkbox, and from the context menu choose to Insert->String:

This will create an Untitled String variable as an input to your new service.

  • Name the new string string1:

  • Add another string to the service, and name it string2:

You can now insert steps into the service that will operate on the inputs.

Step 3: Insert Steps into the Service #

In this step: You will insert two pre-defined utility services as steps in the customWriteToLog service. The WmPublic package provides commonly used utility services. In this step you will use the pre-defined pub.string.concat and pub.string.toUpper steps.

To insert the service steps:

  • Select the
  • Tree tab at the bottom of the Flow Editor view, and expand the Palette on the right side of the view:

  • From the
  • Insert section of the Palette, select Invoke… to invoke another service as a step within your flow:

Note: As with the creation of the input/output variables, you may add an Invoke step to your flow service in several ways:

1) Click-and-click: click on Invoke in the Palette and then click again on the white space of the Tree area of the Flow Editor

2) Click-and-drag: click to select Invoke in the Palette and then drag it onto the white space of the Tree area of the Flow Editor

3) Toolbar insert button: instead of using the Palette on the right side of the Flow Editor, you may use the Insert button

at the top of the window in the Designer toolbar (use the drop-down arrow for the same options as the Palette, or click the button to create the same type of step as previously built (default is the Invoke… selection dialog box))

4) Right click: right click on the white space of the Tree area of the Flow Editor, and choose Insert->Invoke… from the context menu

5) Drag from Package Navigator: as you will see later, you may also drag services directly from the Package Navigator view

6) Copy/paste: steps may be cut/copied from other parts of a flow or copied from the Package Navigator view and pasted into your flow

Insert the Invoke step into your flow. Because Invoke… is not a specific service, Designer will display a dialog box to prompt you to select the service that you would like to invoke.

The Open dialog displays the IS packages.

  • Scroll down to the WmPublic package and expand WmPublic -> pub -> string:

  • Select the concat service and click OK:

This will insert an invocation to the built-in pub.string:concat service as a step in your flow. The fully qualified name of this service is: pub.string:concat. Every element name in all the packages on the IS must have a unique fully qualified name.

Click on the Pipeline view in the bottom panel of Designer:

  • Now use the drag and drop way of adding another step to your flow service by finding the pub.string:toUpper (also located in the WmPublic package) in the Package Navigator view, select and drag and drop it onto your flow editor:

  • Your flow service should look like the following:

  • Add a third step to your flow by dragging the built-in service: pub.flow:debugLog (again located in the WmPublic package) and dropping it onto your flow editor:

Note: You may change the order of steps within a service by dragging and dropping or by using the Shift buttons on the Designer toolbar:

Step 4: Map the Service Inputs #

In this step: You will map the inputs to the customWriteToLog service using the Pipeline tab, which is by default located in the bottom panel of Designer.

To map the pub.string:concat service step:

  • select the pub.string:concat service step, then select the Pipeline tab:

The Pipeline tab is divided into three sections:

  • Pipeline In
  • <selected service object>
  • Pipeline Out

The Pipeline toolbar provides various pipeline management functions, including the Link tool.

Important: You use the Pipeline tools by first selecting one or more variables that you want to act on. When you select a variable, the applicable tools will become available in the toolbar.

For example, to map the variable string1 to the variable instring1:

  • Select string1 in the Pipeline In section, then select inString1 in the Service In section

The Link tool is now active.

  • Click on the Link tool

The Link tool maps string1 to inString1.

  • Use this technique to map additional variables in the pub.string:concat step as follows:

To map the pub.string:toUpper step:

  • Select pub.string:toUpper, and link the objects as follows:

To map the pub.flow:debuglog step:

  • Select pub.flow:debuglog and link the objects as follows:

  • Use the mapping tool to connect the variables as follows:

You have added steps to the Flow service and mapped them; you can now run the service.

Step 5: Run the Flow Service #

In this step: You will run the Flow service and enter values for the input strings.

To run the service:

  • Select the Save icon in the Designer toolbar:

  • Select the Run toolbar button drop-down then Run As -> Run Flow Service:

The Enter Input for ‘customWriteToLog’ dialog opens. Enter Hello- for the value of the string1 variable and World for the value for the string2 variable and click the OK button:

string1 Hello-
string2 World

The Results view displays the value of all variables after all the steps in the flow service executes:

Step 5: Maintaining the Pipeline #

Services have the concept of a pipeline. The pipeline contains all the variables and their values that are present at a given point in the service.

In this step: You will edit the pipeline to discard data that is not needed at the specified steps.

Important: For normal Invoke steps, you can drop variables only from the Pipeline Out side of the Pipeline view.

To edit the pipeline for the pub.string:concat step:

  • Select pub.string:concat, then select the unmapped variables in the Pipeline Out section:

  • Click on the Drop toolbar button to remove the unmapped variables from the service pipeline:

The Drop icon indicates that the selected variables will be dropped from the service pipeline:

  • Repeat this process for the pub.string:toUpper and pub.flow:debuglog steps; however, leave the variable message in the Pipeline Out section of the pub.flow:debuglog step:

Save the service. You can now run the Flow service and verify the output by examining the server log.

Step 6: Run the Service and Verify the Output #

In this step: You will run the Flow service and verify its output by examining the contents of the server log.

To run the service:

  • Select Run from the Designer toolbar and enter values for the strings as you did in Step 5.

Designer displays the Results:

To examine the server log:

  •  Log into the Integration Server Administration interface by opening one of the following URLs in your browser of choice:

http://localhost:5555 or http://<hostname or IP address>:5555

The Integration Server displays the Authentication Required dialog:

Use the following values to log into the Integration Server:

Field Value
Username: Administrator
Password: manage

Note: These values may be stored from a previous session. In this case, simply select OK.

Firefox displays the Integration Server page:

  • select Server from the Logs section of the left menu:

The Logs > Server page displays the service output:

Conclusion #

You have created, run, maintained, and verified a Flow service. You are now ready to develop more complex services as described in the next tutorials.

To import the solution of this tutorial download Completed Export of 2. Create and Run a Flow Service.zip and follow the directions in the Import an IS Package tutorial. 


Read in this series: