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.
To create the mediation flow implementation:
- In the assembly editor, double-click on the HelloWorldMediation component
and click Yes in the Open window, then click OK in the
Generate Implementation window. The mediation flow editor opens.
- 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, respectively. (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 dialog box 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.
Note: At
some points in your development activities, a Tip dialog
box may open to help guide you in making development decisions. For
the purposes of this sample, you can simply close the Tip dialog boxes
and adhere to the sample instructions.
- Double-click the input_map primitive
to create its map. The New XML Map window opens. Click Finish.
The XML mapping editor opens.
- In the XML mapping editor, fully expand the left and right
trees.
- Wire title on the left to name on the right.
This creates a Move map operation.
- Wire firstName on the left to the Move operation
in the middle. This changes the operation into a Concat operation.
- Wire lastName on the left to the Concat operation
in the middle. 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, first name and last 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 mapping 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 mapping 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.
- 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 dialog box 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 dialog box, select ErrorHandling,
as shown in the following figure:
- Click OK to close the Subflow
Selection dialog box. The ErrorHandling subflow opens.
- In the palette of the new subflow, click Error
Handling 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 terminal, 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 dialog box
opens.
- In the dialog box, expand Service Message
Object Details and click Change.
The Change Message Type dialog box opens.
- Select the Any message type radio
button, as shown in the following figure:
- Click OK to close the Change
Message Type dialog box and then close the in dialog
box.
- Press Ctrl-S to save the subflow
and then close the subflow. A File Changed dialog box 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.
- Wire the fail terminals on the bottom right sides of
the HelloServicePartner and output_map to
the ErrorHandling subflow.
- Click the Request tab and then
drag and drop the Subflow entry from the palette
to the canvas. In the Subflow Selection dialog box, select ErrorHandling and
click OK.
- On the canvas, select the ErrorHandling subflow
and then connect the fail terminal of the input_map to
the ErrorHandling subflow. The complete Request
flow should resemble the following figure:
- Click the Response tab. The complete
Response flow should resemble the following figure:
- Now that you have completed your TODO on the request and
response flows, right-click the TODO dialog boxes 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.
Congratulations – the authoring steps are done! Now it is
time to test.