< Previous | Next >

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.

To create the mediation flow implementation:
  1. 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.

  2. 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:
    Wired operations in mediation flow
  3. When the Select Reference Operation dialog box opens, select the getHello operation (as shown below), then click OK.
    Select the target operation
    What you have indicated here is that you will be invoking the getHello operation as part of implementing the callHello operation for this component.

  4. 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:
    Request flow
    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.

  5. Double-click the input_map primitive to create its map. The New XML Map window opens. Click Finish. The XML mapping editor opens.

  6. In the XML mapping editor, fully expand the left and right trees.

  7. Wire title on the left to name on the right. This creates a Move map operation.

  8. Wire firstName on the left to the Move operation in the middle. This changes the operation into a Concat operation.

  9. 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:
    XML mapping editor

  10. Select the Concat operation and then go to the Properties view and click the General tab.

  11. 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:
    Space character delimiter
  12. Save and close the XML mapping editor.

  13. Save the mediation flow editor.

  14. 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:
    Response flow

  15. Double-click the output_map primitive. In the New XML Map wizard, click Finish to create the new map.

  16. Map the incoming output1 field to the outgoing result field, as shown in the following figure:
    Mapping the output1 field to the result field

  17. Save and close the XML mapping editor.
  18. Save the mediation flow editor.

  19. 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:
    Warning on callout response
    The warning occurs because you have not accounted for a situation where a call to the Web service fails.

  20. For encapsulation of error handling and to more easily add logging, complete the following steps to add a subflow:
    1. In the palette, click Mediation Subflow and then click Subflow, as shown in the following figure:
      Picture of the Subflow
    2. Drag Subflow from the palette to the canvas. The Subflow Selection dialog box opens.
    3. Click the New button. The New Mediation Subflow wizard opens.
    4. In the Name field, type ErrorHandling, as shown in the following figure:
      Picture of the New Mediation Subflow wizard
    5. Click Finish.
    6. In the Subflow Selection dialog box, select ErrorHandling, as shown in the following figure:
      Picture of the Subflow Selection dialog box
    7. Click OK to close the Subflow Selection dialog box. The ErrorHandling subflow opens.
    8. In the palette of the new subflow, click Error Handling and then click the Fail primitive, as shown in the following figure:
      Picture of the selected Fail primitive
    9. Drag the Fail primitive from the palette to the canvas.
    10. Wire the right edge of the in terminal to the Fail terminal, as shown in the following figure:
      Picture of the wired terminals
    11. Since no messages will exit the flow, right-click the out terminal and select Delete.
    12. 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.
    13. In the dialog box, expand Service Message Object Details and click Change. The Change Message Type dialog box opens.
    14. Select the Any message type radio button, as shown in the following figure:
      Picture of the Change Message Type dialog box
    15. Click OK to close the Change Message Type dialog box and then close the in dialog box.
    16. 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:
      Picture of the File Changed dialog box
    17. Select Save and Reload. This reloads the changes that you made to the ErrorHandling subflow in the HelloWorldMediation flow.
    18. Wire the fail terminals on the bottom right sides of the HelloServicePartner and output_map to the ErrorHandling subflow.
    19. 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.
    20. 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:
      Picture of the finished Request flow
    21. Click the Response tab. The complete Response flow should resemble the following figure:
      Picture of the finished Response flow
  21. 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.

  22. Save and close the mediation flow editor and the assembly editor.

Congratulations – the authoring steps are done! Now it is time to test.
< Previous | Next >





Feedback



This information center is powered by Eclipse technology. (http://www.eclipse.org)