Build the request flow
Build the request flow for the getQuote operation: create the mediation primitives, set their properties, and wire the flow.
About this task

To build the request flow, complete the following steps:
Procedure
- When the mediation flow opens, you will see a tip explaining how to invoke a service. Since you have already added a callout to the target service using the Service Integration template, you can close the tip.
- Click the Tracing palette category to expand the group.
- Click the Trace primitive and drop
it onto the request flow canvas, and rename the primitive Trace.

- Select a Mapping primitive from the Transformation folder in the palette, drop it onto the request flow canvas, and name it Lookup.
- Select a Message Filter primitive from the Routing folder, drop it onto the request flow canvas, and name it Filter.
- Select a Mapping primitive from the Transformation folder, drop it onto the request flow canvas, and name it TransformToDelayed.
- Select another Mapping primitive, drop it onto the request flow canvas, and name it TransformToRealtime.
- Select a Message Element Setter primitive from the Transformation folder, drop it onto the request flow canvas, and name it SetCustomerType.
- Before you proceed to wire the primitives, right click the canvas and make sure that the Automatic Layout option is on.
- In the request flow canvas, wire the primitives:
- The output terminal of getQuote : StockQuoteService to the input terminal of Trace
- The output terminal of Trace to the input terminal of Lookup
- The output terminal of Lookup to the input terminal of Filter
- The default terminal of Filter to the input terminal of SetCustomerType
- The match1 terminal of Filter to the input terminal of TransformToRealtime
- The output terminal of SetCustomerType to the input terminal of TransformToDelayed
- The output terminal of TransformToRealtime to the input terminal of getQuote : RealtimeServicePortTypePartner
- Select Filter. In the Properties view, select the Terminal tab. Right-click the Output terminal and select Add output terminal. In the New Dynamic Terminal window, take the defaults of Terminal type match and change the Terminal name delayedTime. Select OK.
- Wire the delayedTime output terminal of Filter to the input terminal of TransformToDelayed.

- You will now add the business object that was created earlier
to the correlation context of the input node getQuote :
StockQuoteService. This enables the property subscriptionLevel to
persist in the message flow. Click getQuote : StockQuoteService input
node and switch to the Details tab in the Properties view. In the Correlation
context field, click Browse. Select
SubscriptionInformation under matching data types, and click OK.
The URI, {http://Resources}SubscriptionInformation, now appears in Correlation
context .

- Click Trace in the request flow
canvas to see the primitive's properties in the Properties view. Click
the Details tab to view the properties. Send the trace output to the
Server Logs view. Ensure that these properties are set:
Table 1. Trace properties Property Value Description Destination Local Server Log Outputs messages to the Server Logs view. Message {0}, {1}, {2}, {3}, {4}, {5} Includes the following information in the output: - {0} - the time stamps when the Trace primitive was invoked.
- {1} - the message ID from the SMO.
- {2} - the name of the Trace mediation primitive instance that generated the trace message.
- {3} - t name of the module, containing the Trace mediation primitive instance, that generated the trace message.
- {4} - the part of the SMO, as specified by the Root property XPath.
- {5} - the version of the SMO.
Root path / The scope of the message and SMO to be inserted into the trace message at insert {4}. 
- Select Lookup in the request flow canvas, hover over it
and select
. Select the out message and set its type to StockQuoteService:getQuote:getQuoteRequestMsg.

- Double-click Lookup. In the New
XML Map wizard click Next. Make sure the Message
Root is "/" and then click Finish.

- In the map, wire the source body getQuote to the target body getQuote.
- Fully expand the source getQuote. On the target, expand context > correlation. Wire the source customerID to the target subscriptionLevel. Change the transform to the Lookup transform. In the Lookup engine field, select Comma Separated Value File Lookup. For CSV file, browse and select CustomerType.csv from the Resources library. Click Save and then close the map.
- Click Filter in the request flow
canvas. Select the Terminal view:
- Click match1 in the Output terminal list. The properties of the match1 terminal appear on the right.
- In the Terminal name field, change the name to realtime.
- By default, the message is sent to the TransformToDelayed
primitive. You need to set the pattern for mapping to TransformToRealtime.
Select the Details tab. In the Filter table, click Add... and
enter the following values:
Table 2. Filter table properties Column Value Pattern /context/correlation/subscriptionLevel = 'premium' Terminal name realtime Pattern /context/correlation/subscriptionLevel = 'regular' Terminal name delayedTime 
- A promoted property can be changed by an administrator
at run time. The pattern property can be changed at run time to change
the quality of service. To promote the pattern property:
- Click the Promotable properties tab.
- Click the promoted check box of the realtime [Pattern] property.
- Click the alias Filter.realtime. Type PREMIUM_SERVICE to rename the alias.

- Select SetCustomerType. In the
Properties view Details tab, select Add. Set
the value regular into the correlation subscriptionLevel and
then click Save.

- Set the properties for the Mapping primitive TransformToDelayed:
- Select the TransformToDelayed primitive in the request flow canvas and double-click it.
- Click Next to see the root, input, and output message types that will be mapped. Click Finish to accept the defaults. This launches the map editor.
- On the left side, the Input object side, expand body
> getQuote > request. In the Output object side, the right
side, expand body. Click symbol on the left
side and drag it to symbol on the right side to wire them together
and create the mapping.

- Save your changes and close the map editor. The mapping file is displayed in the Details tab of the
Properties view.

- Similarly, set the properties for the Mapping primitive TransformToRealtime:
- Select the TransformToRealtime primitive in the request flow canvas and double-click it.
- The New XML Mapping wizard opens. Click Next to see the root, input, and output message types that will be mapped. Click Finish to accept the defaults. This action opens the map editor.
- On the left side, expand body > getQuote > request. On the right side, expand body. Click symbol on the left side and drag it to symbol on the right side to create the mapping.
- Save your changes and close the map editor. The mapping file is displayed in the Details tab of the
Properties view.

- Save the request flow.
