< Previous

Building the mediation flow

Map your request and response operations, add and wire a custom mediation primitive in the palette, and create your custom code in a Visual snippet.

Open the CustomMediationFlow component in the mediation flow editor.
  1. In the Business Integration view, expand the CustomMediation module.
  2. Open the Assembly Editor by double-clicking on the CustomMediation module assembly icon.
  3. In the module assembly diagram, right-click on the CustomMediationFlow component and choose Generate Implementation.
    Screenshot of selecting Generate Implementation in the CustomMediation module
  4. Click OK to generate the mediation flow in CustomMediation. This action opens CustomMediationFlow in the mediation flow editor.
  5. Begin by defining the source and target operations. In the Operation connections section, wire StockQuoteService interface's getQuote operation to StockQuoteServicePartner interface's getQuote operation. You will see the request flow with an input and a callout for the operation.
  6. Add the PreferenceInformation business object to the correlation context of the input node getQuote : StockQuoteService. This will allow the property isPreferred to persist in the message flow. Click on getQuote : StockQuoteService and switch to the Details tab in the Properties view. In the Correlation Context field, click Browse. Select PreferenceInformation under matching data types, and double click. {http://CustomMediation}PreferenceInformation now appears in the Correlation Context field.
    Screenshot of adding the PreferenceInformation business object to the correlation context field
  7. Define the request flow. Select a Custom Mediation primitive from the palette, drop it onto the request flow canvas.
  8. In the request flow canvas, wire the output terminal of getQuote : StockQuoteService to the input terminal of CustomMediation1.
  9. Wire the output terminal of CustomMediation1 to the input terminal of the callout node getQuote : StockQuoteServicePartner.
  10. Click the Details tab in the Properties view.
  11. In this sample, you will create a Visual snippet. Click the Visual button for Implementation. At the warning message, click Yes.
  12. Keep the default Root value /. This will allow the complete message object to be available to the custom mediation.
  13. In the Visual Snippets view, there are custom snippets that will help you build your custom code. In the Visual snippet editor, perform the following tasks:
    1. Use the custom snippet get SMO part to extract the symbol from the message body. From the SMO services folder in the Visual Snippets view, drag the get SMO part into the Visual snippet editor.
    2. Hover your mouse over each input terminal of the part to see the expected input parameter:
      get SMO part in visual snippet editor
    3. The first input is a data object. From the tray at the right of the snippet editor, drag input1 onto the editor, and wire it to the first input of get SMO part.
    4. The second input expected is an XPath expression. From the palette, drag an expression onto the editor. Click the expression and type "/body/getQuote/symbol". Wire the expression to the second input of get SMO part
    5. From the palette, add an expression. Click the expression, and type symbol. Wire the output of get SMO part to symbol.
      Wired get SMO part in the visual snippet editor
    6. Next, determine if the symbol is "ibm". Use the text equal to custom snippet from the text folder in the visual snippets view. This snippet compares text and produces a true or false result. Give it the inputs symbol and "ibm". From the palette, drag a choice activity onto the snippet. Wire the result of text equal to to the choice activity.

    7. Earlier, we added PreferenceInformation to the correlation context to indicate that the correlation context will contain a PreferenceInformation business object. If the result is true, the choice activity creates an instance of the PreferenceInformation business object, and sets its isPreferred flag to true. It then sets the business object in the correlation context:

      Build the choice activity as follows:

    8. From the SCA services folder, drag the custom snippet create specific BO into the choice activity. A list of available business object appears. Click PreferenceInformation, and click OK
    9. Add an expression, click it, and type preferenceInfo. Wire the output of the create specific BO activity, create PreferenceInformation, to preferenceInfo.
    10. Add another expression, click it, and type true.
    11. Add another expression, click it, and type preferenceInfo.isPreferred . Connect true to preferenceInfo.isPreferred
    12. Add an expression, click it, and type preferenceInfo.
    13. Add an expression, click it, and type input1.context.correlation . Connect preferenceInfo to input1.context.correlation .
    14. From the palette, drag a return activity onto the canvas. Add an expression, click it and type input1. Wire input1 to the return activity.
    The completed snippet is shown below:

    Completed visual snippet

Feedback
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.
< Previous