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.
- In the Business Integration view, expand the CustomMediation module.
- Open the Assembly Editor by double-clicking on the CustomMediation module
assembly icon.
- In the module assembly diagram, right-click on the CustomMediationFlow component
and choose Generate Implementation.

- Click OK to generate the mediation flow
in CustomMediation. This action opens CustomMediationFlow in
the mediation flow editor.
- 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.
- 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.

- Define the request flow. Select a Custom Mediation primitive
from the palette, drop it onto the request flow canvas.
- In the request flow canvas, wire the output terminal of getQuote
: StockQuoteService to the input terminal of CustomMediation1.
- Wire the output terminal of CustomMediation1 to the input
terminal of the callout node getQuote : StockQuoteServicePartner.
- Click the Details tab in the Properties
view.
- In this sample, you will create a Visual snippet. Click the Visual
button for Implementation. At the warning message, click Yes.
- Keep the default Root value /. This will allow the complete
message object to be available to the custom mediation.
- 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:
- 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.
- Hover your mouse over each input terminal of the part to see
the expected input parameter:

- 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.
- 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
- From the palette, add an expression. Click the expression,
and type symbol. Wire the output of get
SMO part to symbol.

- 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.
- 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:
- 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
- Add an expression, click it, and type preferenceInfo.
Wire the output of the create specific BO activity, create PreferenceInformation,
to preferenceInfo.
- Add another expression, click it, and type true.
- Add another expression, click it, and type preferenceInfo.isPreferred .
Connect true to preferenceInfo.isPreferred
- Add an expression, click it, and type preferenceInfo.
- Add an expression, click it, and type input1.context.correlation .
Connect preferenceInfo to input1.context.correlation .
- 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: