Making sequential calls
Many people are unaware that Oracle mediator can be configured
This posting presents an example of a mediator component
calls a web service,
then combines the web service response data with the original
and calls a File adapter with the combined payload.
The composite.xml for this example looks this
The processing is completed using a single Mediator component
Routing Rule as follows:
Here are the steps to create the example.
New Application and SOA Project
First we'll create a new Application
In JDeveloper Choose File->New Application
Name the application MediatorExamples
or choose your own name.
Set the SOA Project name to MediatorSerialCallsExample
Press the Finish button to create the application and create the
Before we add the mediator we need to define the type that will
in its interface.
We will create a new XML Schema to define the type.
In the Application Explorer,
Right Click on the Newly created MediatorSerialCallsExample
select the New option
Under the General category select XML and in the items pane on
right select 'XML Schema'
Name the new XSD file EmployeeRequest.xsd
Edit the new file and replace all lines by pasting in the XSD
from the following link.
Then save the newly created file.
Open the composite.xml file
Drag a Mediator control from the Component Palette to the center
of the composite diagram.
Name the Mediator component Mediator1
Choose the One way interface option in the template dropdown
An input text box should appear, select the magifying glass icon
the EmployeeRequest Schema in the project
(we just added it in the previous set), expand and select the
Press OK to create mediator
new Web Service
Next we will create a new Web Service that the mediator
To create the simple web service follow the steps in this post.
to create or download the Web service
web service partner link to the composite
Open the composite.xml file and drag the a Web Service icon from
component palette to the
External References column of the composite diagram.
Name the service: departmentFinder
in the WSDL url field paste the address for the remote wsdl
If the url is unkown, it can be located in Enterprise Manager
See the 'Create a new Web Service' article at the link above.
Next press Port dropdown, (Don't press the green finder icon),
the dropdown should auto fill based on the wsdl resolution.
Check the 'copy wsdl into project' check box, to avoid annoying
in the future when
opening the JDeveloper
project is opened without the web service endpoint being
Select NEVER for transaction and press the OK button.
Press OK to localize project references to point to the local
Next return to the composite diagram click and drag a
connnct wire from departmentfinder partner link to Mediator.
file adapter partner link to the composite
Next drag a File Adapter to the External References column of
Set the value of the ServiceName to WriteEmployeeDetails
press the Next button
Select Define from operation
Select the Write file operation.
Pick a file location where files will be written, for example
/tmp or c:\temp
Set the file name pattern to emp_%SEQ%.txt
At step 6 in wizard click the magnifying glass and
select the EmployeeRequest element
Then press the finish button.
Return to the Composite diagram editor and drag a wire the File
partner link to the
The composite diagram should now match the first diagram shown
beginning of this article.
Mediator Routing Rules
Open the coposite diagram and double click on the mediator
open the mediator editor.
Two Static Routing rules should exist.,
One rule to call the Web Service, which has a Request section, a
Synchronous reply section and a Fault section.
And another rule to call the File Adapter which does not have a
Synchronous reply or Fault section.
First we will configure the Web Service Call Rule.
Click on the black X transform icon beside the 'Transform Using'
the section with a target operation
The Request Transformation MapDialog should appear:
Select Create new Mapper File
and accept the default name
Press the OK button to create the transform.
In XSL mapper map eDept on left to arg0 on right.
This will pass the department number input value to the web
Save and Close the transformation file.
Now still on rule 1, click the gear icon beside the
Operation>> in the Synchronous Reply
The Select Target Type Dialog will appear.
expand WriteEmployeeDetails and choose the Write operation.
This instructs mediator to call another service after receiving
response from the first service.
We have the option to send only the response data from the first
to the second endpoint or we can
combine the response from the web service with the
original mediator request data.
We will combine the response data with the request data that was
to the mediator.
Click the Black X icon in the Sync Response Section to create a
Check the Create new mapper file radio button and accept the
IMPORTANT: Check the box
Request in the Reply Payload"
Press the OK button to launch the xform editor.
Now in transformeditor you will see two sources on the left
originial request sent to the mediator and
the response from the web service the mediator, for example
from the web service)
Using the Mapper, map the following fields
The completed transformation is shown in the diagram below:
Finally, save and close transform editor
Return to the mediator editor and locate rule 2.
This rule was created automatically when the File Adapter
was associated with the Mediator by dragging a wire between
the components in the composite diagram.
The second rule is not necessary in this application, since we
expect the mediator to call the file adapter
calling the web service.
Click on the second rule which and choose the red X icon top
the mediator editor window to
delete the rule.
The final routing section for the mediator should appear as
Save all project files by choosing File->Save All from the
Compile the project by right clicking on the
project in the Application Explorer.
Ensure there no errors are listed in the JDeveloper
Deploy the project to a SOA Partition on a running WLS Server by
clicking on the project and choosing the deploy ->
Deploy to Application Server option.
Open the Enterprise Manager console using a browser.
For example http://localhost:7001/em
Expand the Farm node and locate the mediatorSerialCallsExample
composite in Enterprise Manager.
Press the test button.
Supply values for the mandatory fields (prefixed with *)
be sure to use a valid dept number value of 1,2 or 3
Do not enter values for depname, org and cost ctr
they will be added by data returned by the web service
Press the "Test Web Service"
Note: The Mediator is configured to use a one way invocation
so no response will be returned in EM.
After the test, verify the results by viewing the file created
adapter in the specified /tmp or c:\temp directory.
[/tmp] $ more emp_1.txt
<?xml version="1.0" encoding="UTF-8"
The result file should have the combined department information.
The completed example can be downloaded as a zip from