Oracle SOA Suite Online Training

Interested in learning Oracle SOA Suite 12c?
Learn from the author of this blog!
A complete and comprehensive course on the #1 platform on SOA - Oracle SOA Suite

Click here to find the complete course details
Click here to check the first session on Oracle SOA Suite 12c

================================================================================================

Working with a Mediator : Echo Pattern


This blog shows you how to work with a Mediator component in Oracle SOA Suite 11g.
This example uses the Echo pattern of the Mediator. An Echo is a simple "reply to the caller" pattern where the requestor immediately gets back a response.
This is typically used in use cases where a certain message has to be enriched, or some filtering to be done, etc.

Creating a Mediator
Create a new SOA Project, name it MediatorEchoPattern, select empty template


Defining the Schema
To begin with, define the message structures that will be used in the example.
In this tutorial, we will send in a message {firstName, lastName} and get back {fullName}. Based on this, define the xsd file
Rt click on xsd folder --> new --> All technologies --> xml schema --> name it EchoPatternSchema


 
 
Define the schema as shown below



Creating the Mediator
Open composite.xml, drag and drop the Mediator component from the component palette to the components swimlane of the composite.xml
Name it EchoMediator, template as Define Interface Later. This interface will be created when we create a WebService and wire it to this, later.
 
This step creates an empty mediator.

Create a service endpoint
Mediator exists in the Components swimlane which is not directly exposed to the external world. In order to access it, we need to create a service endpoint through which external clients can access this component.
Here, we create a WebService with request and response types as defined in the schema earlier
To create a WebService, drag and drop the Web Service from the component palette to the Exposed Services swimlane of the composite.xml
Name it EchoMediatorClient
In the WSDL url, select the second option Generate WSDL from Schema.
This will open a WSDL generation wizard where we need to select the Interface type and the message types for input and output. Select them as shown below


 
This will create a WebService in the composite.xml
Now, wire the Webservice to the mediator as shown

 
Creating the Echo Pattern
Now that the wiring is done, the only thing remaining is to define the message flow
In this example which is an echo pattern, the request comes from the WebService, goes to the mediator, undergoes some transformation in the mediator, and finally is routed back to the WebService.
Hence, we need to create a routing rule in the mediator with an Echo Pattern

Double click on the mediator component in the composite.xml which will open a .mplan file which is the heart of the mediator component where all the operations of the mediator as defined in the other blog are to be defined.
For this tutorial which is more like a HelloWorld example, just a transformation file would be sufficient.

Click on the + icon of the Routing Rules --> Static Routing Rule --> Echo


This will add a Routing rule section in the file.
Here, we add a transformation file to transform the input message to the output message. Transformation file is mandatory for any type of mediator as that is the link that connects the input to the output within the mediator.
Click on the button at the end of the Transform Using, create a new mapper file and accept the default name

 


This will open up a new wizard, where we can do all the transformations.
In this example, we need to concatenate the firstName & lastName, append hello to it, and assign it to the output
Concat function is available in the component palette at the right when you open the transformation file. Drag and drop this function to the middle section of the wizard,
then drag a line from each of the inputs to it, then double click on the concat function to add hello, and finally map it to the fullName at the right, as shown below


 
Thats it, you're done!

Deploy this project. How to deploy is mentioned in this blog
Select the project under SOA-->soa_infra, click on test





Hope this tutorial helped you introduce working with a Mediator component in Oracle SOA Suite 11g

You can download the entire example(jar) from this location

Thanks for going through my post, feel free to provide a feedback!

7 comments:

  1. Thanks a lot Sir , It is very nice application to understand mediator

    ReplyDelete
  2. Thanks a lot, created my first BPEL process, using your steps..Satendra

    ReplyDelete
  3. VERY EASY TO UNDERSTAND

    ReplyDelete
  4. Thanks, great blog...

    ReplyDelete
  5. Thank you so much....this helped me to understand mediator.

    ReplyDelete