Search 800 + Posts

Jan 10, 2010

How to Call Synchronous BPEL Process from Mediator

In this blog I will explain in details about how to built the interactions between Mediator and Synchronous BPEL Process.(Request and Response Pattern)
Please Note that both BPEL as well as Mediator are the complementary components and do similar tasks.
BPEL is process based and Mediator is routing based.
BPEL is usually for long running process where as Mediator is for short and fast messages.

As stated this blog is about design Interaction Pattern between Mediator and Sysnchronous BPEL process .
Example -In this example we have WebService that will take Input for Sales Order and call Mediator process.
If Order Price is < 50 Mediator route the flow to Partner link Service  to Insert the data into Sales Order Table.
If Order Price is > 50 Mediator route flow to BPEL Process , to validate Customer Raiting. We can also define Sysnchronous Reply in Mediator Process.In My example I define Sysnchorous reply as SERVICE to Insert the Sales Order Data in table.

Complete Flow . -
Below is complete flow of my Process. I have Web service to received Input , Meditor to Route the process.BPEL to Validate the Rating and 2 database Adaptor to validate the data.


Step #1
Define your Message Structure ( Structure for your Input data).In my case I have defined a simple Order Structure with few elements, as shown below.

Save it as OrderInfo.xsd

 Step # 2
My Requirements
  1. Let user Enter Sales Order data Manually.
  2. Insert Data into Sales Order Table  if Order less than 50.
  3. Validate Customer rating if Order More than 50 and then Insert into Sales  Order table.
Requirement #1
Create a Web Service by Dragging "Web Service" Service Adapters from Component Palette and the associate "Order Info" Schema " by populating the OrderInfo.xsd in URL field in Request. Tab

Requirement #2
Define a Partner Link by Dragging "Database Adapter"  from Component Palette , drop it in External References, name it "InsertOrder".
Configure this database adapter to Insert the data into so_info table.Please note that in my example structure of so_info database table and "OrderInfo.xsd" file is same.

Requirement #3
Drag Mediator Service component in Component and link "WebService" and Database Adaptor. (Pls refer Complete flow diagram)
Configure the Mediator component to Insert data accepted as Input in webService  to "InsertOrder" partner link as shown below.

Requirement #3
As part of requirement 3 , I need to validate the customer rating if Order amount is MORE than 50.For that I have designed a BPEL Process which will take "OrderInfo.xsd" as input and then call the PartnerLink "CheckCustStatus" to check the Credit Status of Customer.
While desiging the BPEL Process make sure that you assign "OrderInfo" Message type to
  1. Input - Process Request Message
  2. Output - Process Response Message
 Step A -
Import "OrderInfo" Message structure in BPEL Process shown Below. -
Click the BPEL Process > Click the Schema and then > Import Schema

Step B -

Once you imported your Message Type .Assigin it to Input and Output variable of your Process.In my Example I want my Input and Output Variable should be of same structure , so I associate same message
structure with input and output variable.

To fuilfill my requirement , I have bulit a filter in Mediator process and called a BPEL process to validate the Customer Rating if Order is More than 50.Also I want to pass the same "OrderInfo"Message Structure to BPEL Process.For that I have already assign "OrderInfo" Messaage type to  

  1. Process Request Message

  2. Process Response Message  , please verify that.If it is not assigned yet , assign that as shown below.

As shown above I have selected -Message Type  > Process WSDL >  Assign the OrderInfo Structure to Request and Response Message Type.
Below is the BPEL Process , this Process Take the Input data in OrderInfo Structure and then Read the Customer Name and Get Credit Rating for the Customer.I am using the "Database Adapter"Parther Link  to read the customer credit rating from database table.

Once BPEL Proces is ready configure Mediator to Call the BPEL Process to validate rating if Order Total is Greate than 50 as shown below.
Mediator Structure . - Here I set the Routing Rules.

That's it .

Below are details of I/p and O/p


  1. I have a dought and this question is my asked me ?
    1)is there any types in mediator
    2)can i use the mediator to pick the data from mediator ?

  2. Mediator - it is mostly used as BUS and for routing purpose,plus we can used mediator to capurure events.

    as per your question "can i use the mediator to pick the data from mediator " , can you please provide some additional details like how and what data you want to pick.

  3. Hi,
    Could you please elaborate your statement "BPEL is usually for long running process where as Mediator is for short and fast messages"...

    I have to route to 3 different places after transformation... But if i am able to transform it in the Mediator then what is the use of BPEL Process ??


  4. What exactly I want to say here was , use Mediator for
    2.Validation of Incoming messages
    3.Transformation and

    As your requirement to route into 3 places after tranformation , I guess Mediator is good choice

  5. In which situation we use pick activity?

  6. The pick activity provides two branches, each one with a condition. The branch that
    has its condition satisfied first is executed.

    This activity waits for the occurrence of one event in a set of events and performs the
    activity associated with that event. The occurrence of the events is often mutually
    exclusive (the process either receives an acceptance or rejection message, but not both).
    If more than one of the events occurs, then the selection of the activity to perform
    depends on which event occurred first. If the events occur nearly simultaneously,
    there is a race and the choice of activity to be performed is dependent on both timing
    and implementation.

    The pick activity provides two branches, each one with a condition. When you
    double-click the Pick icon, the pick activity displays these two branches: onMessage (on the left) and onAlarm (on the right).
    The onMessage branch contains the code for receiving a reply, .
    The onAlarm branch contains the code for a timeout, for example, after one

    Whichever branch completes first is executed and the other branch is not.

    Hope that helps

  7. What is the benefit of doing transformation in Mediator vs Doing the Stransformation in bpel with Transform activity. Should we do all the transformation in mediator than in bpel

  8. Well it's all depend on your Technical an business need .
    Mediator is more like a routing activity , where as BPEL is to design complex process.If you feel you can do Transformation in Mediator then do it .Don't design BPEL just for transformation

  9. How to generate xml from another xml?

  10. Where there are many tools that will help you do so , but what actually your requirement is ?

    1. I want generate copy of xml file from fault-policies.xml in Oracle SOA Suite11g

  11. Nowadays, you will discover a few call routing programming programs, which give insight ability based routing framework and offer highlights that are in the best support of any business.