Build it yourself

This section shows you how to create the mediation flow described in the Overview. Detailed instructions for importing the module into WebSphereŽ Service Registry and Repository (WSRR) and creating policy attachments can be found in Run the Sample. To build the mediation module, follow these steps:

Import the partial library and pre-written services into WebSphere Integration Developer

This download includes three WebSphere Integration Developer projects that include all the code for the Mediation Policies Sample. To import the project into WebSphere Integration Developer, complete the following steps:

  1. Download mediationPoliciesSample1_pi1.zip to a temporary directory.
  2. In WebSphere Integration Developer, from the menu bar click File > Import. The Select page opens.
  3. Select Other > Project interchange as the import source.
  4. Click Next. The Import Projects page opens.
  5. At the end of the From zip file field, click Browse.
  6. Select mediationPoliciesSample1_pi1.zip.
  7. Select the check boxes for the AddressServices and AddressLibrary projects.
  8. Click Finish.
  9. Work through the Workspace Migration wizard, selecting all projects from the list for migration.
  10. Click OK on the Migration Validation window.

Create the mediation module and set up the dependencies

To create the AddressMediation module, complete the following steps:

  1. In the Business Integration view, from the menu bar, click File > New > Mediation Module.
  2. In the Module name field, enter AddressMediation.
  3. In the Target runtime environment field, select WebSphere ESB Server V7.0 or WebSphere Process Server V7.0 (depending on your runtime environment).
  4. Click Finish. The module is created: wait until the automatic build process completes.
  5. Expand the Address Mediation project and double click on Dependencies.
  6. Expand the Libraries section.
  7. Click Add... The Library Selection window opens.
  8. Select the AddressLibrary project.
  9. Click OK.

  10. Save and close the Dependencies view. This allows the AddressMediation module to use the predefined interfaces and business objects in the AddressLibrary project.

Create and wire the mediation flow

To create the basic mediation flow, complete the following steps:

  1. Expand the AddressMediation project.
  2. Double-click the Assembly Diagram. The Assembly Diagram view opens, showing the AddressMediation component.
  3. Right-click the AddressMediation component, and click Add > Interface. The Add Interface window appears.

  4. Select the AddressService interface.
  5. Click OK.
  6. Right-click the AddressMediation component, and click Add > Reference. The Add Reference window opens.
  7. Select the AddressService interface.
  8. Click OK.
  9. Drag an Export from the palette to the canvas.
  10. Wire the export to the AddressMediation component.
  11. If prompted, click OK.
  12. Right-click the export, and click Generate Binding... > Web Service Binding. The Transport Selection dialog appears.
  13. On the Configure Web Service Export window select SOAP 1.1/HTTP. Click Finish.
  14. Drag an Import from the palette to the canvas.
  15. Right-click the import, and click Add Interface.
  16. Select the AddressService interface and click OK.
  17. Wire the the AddressMediation component to the import.
  18. If prompted, click OK.
  19. Right-click the import, and click Generate Binding... > Web Service Binding. The Web Service Import Details dialog appears.
  20. Use the Browse button to select the USAAddressExport_AddressServiceHTTPPort.

  21. The Configure Web Service dialog appears. Select SOAP 1.1/HTTP and click Finish.
  22. Click OK.
  23. Right-click the AddressMediation component, and click Generate Implementation. The Generate Implementation window appears. Click OK.
  24. The Address Mediation Window opens. Click on validateAndFormat and choose Service Integration from the Mediation Flow Template Options.
  25. The Integrate Services dialog will appear. Click Add and accept the defaults on the Select a Reference window by clicking OK.
  26. Click OK to the Integrate Services dialog which will result in a line connecting the validateAndFormat operation from the interface to the reference.

  27. Wire up the request and response paths, linking the Interface and Reference as shown. This leaves the fail terminal of the Callout Response un-wired. You will correct this later.

Add and configure the Policy Resolution Primitive

To add and configure the Policy Resolution primitive, complete the following steps:

  1. Drag a Policy Resolution primitive from the palette under the 'Routing' tab on to the request wire. This adds a Policy Resolution primitive to the flow.
  2. Click the Properties tab.
  3. Click on Description and change Display name to PolicyResolution.
  4. Click the Details tab.
  5. Click Add.... The Add/Edit properties window opens.
  6. In the Policy condition name field, enter country.
  7. In the XPath field, enter /body/validateAndFormat/country.
  8. Click Finish. This defines the policy condition name country 'country' and tells the run time which part of the message to use when processing the gate conditions. Configuration of the Policy Resolution primitive is now complete, with the details panel as shown.

Add and configure the Message Element Setter Primitive

To add and configure the Message Element Setter Primitive, complete the following steps:

  1. Drag a Message Element Setter primitive, under the Transformation tab, from the palette on to the request wire after the Policy Resolution primitive.
  2. Click the Properties tab.
  3. Click on Description and change the Display name to SetTargetAddress.
  4. Click the Details tab.
  5. Click Add.... The Add/Edit properties window opens.
  6. In the Target field, enter /headers/SMOHeader/Target/address.
  7. In the Value field, enter http://localhost:9080/AddressServicesWeb/sca/USAAddressExport.
  8. Click Finish.

  9. Click the Promotable Properties tab.
  10. Select the Promoted check box for the property /headers/SMOHeader/Target/address[Value]. This allows the property to be controlled by mediation policy.
  11. In the Alias field for the property, enter the value targetAddress. This gives the property an easy-to-use name, rather than the default name.


Add and configure the Message Logger Primitive

To add and configure the Message Logger Primitive, complete the following steps:

  1. Drag a Message Logger primitive from the palette under the Tracing tab on to the request wire, after the Message Element Setter primitive.
  2. Click the Properties tab.
  3. Click Description and change the name to LogBodyToConsole
  4. Click the Details tab.
  5. Select a Logging Type of Custom.
  6. In the Handler field, enter java.util.logging.ConsoleHandler.
  7. In the Literal field, enter {4}. The primitive is now configured to print the message body to the system console.
  8. Clear the Enabled check box to disable logging, unless it is turned on using mediation policy.

  9. Click the Promotable Properties tab.
  10. Select the Promoted check box, for the Enabled property. This allows the property to be controlled by mediation policy.
  11. In the Alias field for the property, enter the value logging. This gives the property an easy-to-use name, rather than the default name.

Add and configure the XSLT Transform Primitive

To complete the flow, and create a transform to propagate the fault message, complete the following steps:

  1. Click the Response: validateAndFormat tab. This switches you to the response flow.
  2. Connect the fail terminal of the Callout Response node, to the Input Fault node. The types do not match, so select Transform the message using an XSL Transformation primitive from the Incompatible Message Types menu.

  3. Click the Properties tab. Select Description and set the Display name to CopyFaultInfoToFault.
  4. Click the Details tab.
  5. Click New... The New XML Mapping window opens.
  6. Accept the defaults, and click Next.
  7. Select Message Root '/'.
  8. Click Finish. The Mapping editor opens.
  9. In the left box, expand context > failInfo.
  10. In the right box, expand body > validateAndFormatFault.
  11. Connect context/failInfo/failureString to body/validateAndFormatFault/description. This allows the requester to see the failure description, received from the service.