Create the mediation flow implementation
Finally, it is time to create the implementation for the
HelloWorldMediation component. This component is a mediation flow
and was created for you when you created the mediation module, although
you could also create one by dragging a mediation flow from the palette.
Because of the type of the component, you will use the mediation flow
editor to implement it.
About this task
Procedure
- In the assembly editor, double-click the HelloWorldMediation component
and click Yes in the Open window, then click OK in the
Generate Implementation window. The mediation flow editor opens.
Note: At some points in your development activities, a Tip window may open to help guide you in making development decisions. For the purposes of this sample, you can simply close the Tip windowes and adhere to the sample instructions.
- At the top of the mediation flow editor, you see callHello on
the left and getHello on the right. This is the single operation
from this component's interface and the single operation from
this component's reference. (Note that it is valid to have multiple
interfaces and references for each component, and multiple operations
for each interface and reference. But this is Hello World.)
Select the callHello interface operation. You
will now need to select whether you want to create a mediation flow
that performs a simple map between operations. Note, however, that
you can make any change that you want in the mediation flow editor,
so you are not locked into your choice. In this sample, you will perform
a simple map between operations, so you should select the Operation
Map link shown in the following screen cap:

- When the Select Reference Operation window opens, select
the getHello operation (as shown below), then
click OK.

What you have indicated here is that you will be invoking the getHello operation as part of implementing the callHello operation for this component.
- Next you want to finish the implementation of the flow for
the callHello operation. Because this is a request response
operation, there is one flow for the request and another for the response,
but you start first with the request. At the top of the canvas, click
the callHello Request tab, as shown here:

In the flow area, you see an input node on the left, which represents control reaching your request flow by way of the callHello operation being invoked. The flow then invokes the input_map XSL transform that maps between the input business object of the callHello and getHello operations. The flow then calls the getHello reference operation, which in this case is an external web service. In the flow area of the request, there is a sticky note that contains the tasks that you must perform to fully implement the flow.
- Double-click the input_map primitive
to create its map. The New XML Map window opens. Click Finish.
The XML map editor opens.
- In the XML map editor, fully expand the left and right
trees.
- Wire title on the left to name on the right.
This creates a transform of type Move.
- Wire firstName on the left to the Move transform
in the middle. A Connection Selection Helper is shown.

- Select Primary Connection. This changes the operation into a Concat operation.
- Wire lastName on the left to the Concat operation
in the middle. A Connection Selection Helper is shown again. Select Primary
Connection. You now see three wires coming in, and one
going out, as shown here:

- Select the Concat operation and then go to the Properties
view and click the General tab.
- When the fields are concatenated you want spaces between
the title, given name and family name. Use the delimiter settings
in the General tab of the Properties view
to create these spaces. For the default delimiter, select Space character. The delimiter is reported as (Space character) in the table, as shown in the following figure:

- Save and close the XML map editor.
- Save the mediation flow editor.
- Now you must finish the implementation of the mediation response
flow, to process the response from the web service you invoked in
the request flow and turn it into a response to the caller of this
component. Select the Response tab at the top of the flow
editor, as shown here:

- Double-click the output_map primitive.
In the New XML Map wizard, click Finish to
create the new map.
- Map the incoming output1 field to the outgoing result
field, as shown in the following figure:

- Save and close the XML map editor.
- Save the mediation flow editor.
- Finally, you want to get rid of the warning that you have
not wired the fail terminal for the callout response node, as shown
in the following figure:
The warning occurs because you have not accounted for a situation where a call to the web service fails. - To capture any unhandled errors that might occur in the
request or response flow, implement the Error flow. Click the Error
tab at the top of the flow editor, as shown here:

- For encapsulation of error handling and to more easily
add logging, complete the following steps to add a subflow:
- In the palette, click Mediation Subflow and
then click Subflow, as shown in the following
figure:

- Drag Subflow from the palette to the canvas. The Subflow Selection window opens.
- Click the New button. The New Mediation Subflow wizard opens.
- In the Name field, type ErrorHandling,
as shown in the following figure:

- Click Finish.
- In the Subflow Selection window, select ErrorHandling,
as shown in the following figure:

- Click OK to close the Subflow Selection window. The ErrorHandling subflow opens.
- In the palette of the new subflow, click the Error
Handling folder and then click the Fail primitive,
as shown in the following figure:

- Drag the Fail primitive from the palette to the canvas.
- Wire the right edge of the in terminal
to the Fail primitive, as shown in the following
figure:

- Since no messages will exit the flow, right-click the out terminal and select Delete.
- Now you must change the input message type to Any message type. Hover the cursor over the in terminal and then click the i icon that appears at the top edge of the terminal. The in window opens.
- In the window, expand Service Message Object Details and click Change. The Change Message Type window opens.
- Select Any message type, as shown
in the following figure:

- Click OK to close the Change Message Type window and then close the in window.
- Press Ctrl-S to save the subflow
and then close the subflow. A File Changed window is displayed, as
shown in the following figure:

- Select Save and Reload. This reloads the changes that you made to the ErrorHandling subflow in the HelloWorldMediation flow.
- Switch to the Error tab. Wire the out terminal of Error
Input to the ErrorHandling subflow.

- The Input Response is used to send messages back to the service requester. Since the Input Response is not used here, you can choose to hide it. Right-click the canvas, and select Hide Input Response.
- In the palette, click Mediation Subflow and
then click Subflow, as shown in the following
figure:
- Now that you have completed your TODO on the request and
response flows, right-click the TODO windowes on the canvas of both
the Request and Response tabs and then select Delete to
remove them.
- Save and close the mediation flow editor and the assembly
editor.
This topic only applies to BAW, and is located in the BAW repository. Last updated on 2025-03-13 12:15