Monday, January 20, 2020

12c SOA - BPEL pick activity OnMessage

"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 events is often mutually
exclusive (the process either receives an acceptance or rejection message, but not both).
If multiple events occur, 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 two branches of the pick activity are as follows:
  • Automatically displays below the Pick activity icon.
  • Contains the code for receiving a reply, for example, from a loan service.
  • Does not automatically display; you must manually add this branch by selecting the Pick activity icon and clicking the Add OnAlarm icon.
  • Contains the code for a timeout, for example, after one minute.
OnMessgae with implementation:

Topics covered:

1. Developing a BPEL process which can expose multiple operations to its clients or handle multiple messages request from clients

2. Developing the BPEL process in Top – Down approach

3. Having a pick activity as the first activity in BPEL process

4. Developing a BPEL process Based on WSDL

5. Developing XSD and WSDL from the created XSD.

Sample Description:

Implementing the Calculator service which exposes 4 operations( addition, subtraction, multiplication, division) which takes 2 parameters as input and returns value. Use BPEL to implement the Calculator service and expose it as service so that client can any operations of his choice.

Create a SOA Project with empty composite

Creating XSD
Right click the PickProject –> New –> In “New Gallery” window select “All Technologies” Tab –> In “General” Section select XML –> Select “XML Schema” –> click OK

 XSD used:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="" xmlns="" targetNamespace=""
    <xsd:element name="calculatorInput">
                <xsd:element name="inputParam1" type="xsd:int"/>
                <xsd:element name="inputParam2" type="xsd:int"/>
    <xsd:element name="calculatorOutput">
                <xsd:element name="output" type="xsd:int"/>

Develop a WSDL with 4 operations (addition, subtraction, multiplication, division)

Right click PickProject –> New –> All Technologies –> Web services –> WSDL Document –> OK

 Create a Messages by clicking “+” in message section
 Enter the Message Name –> Click OK
 Create a part element inside the “addInputMsg”.
– Simple way of doing this by dragging and dropping the “CalculatorInput” element from Calculator.xsd on the “addInputMsg”.

– To do this keep “Calculator.xsd” and “Calculator.wsdl” in 2 different window side-by-side as below

 Know drag and drop the “CalculatorInput” element from XSD on to “addInputMsg” of the wsdl
 Create one more message element for addition response by clicking “+” symbol
 create the part by right clicking on “addOutputMsg” element.Specify the Part Name and Reference Value
 creating the other message required for remaining operations

Create a “PortTypes” by clicking “+” in PortTypes section

 Similarly create other operations(Subtraction, Multiplication, division)
 Create a BPEL Process based on WSDL

 By default when the process is created it will create the Receive, Reply activity based on the operation type in wsdl.
Delete the default activities created as part of the process like receive, reply
Drag and drop the pick activity on to the Calculator process
Double click the pick activity and Specify the name and Select “Create Instance” checkbox

 Double click the OnMessage –> Select Partner Link, Operation, variable to hold the data.
Drag and drop the Reply activity on to the OnMessage. Know connect the reply activity with the Partner link.
Drag and drop the assign activity before the reply activity to assign the result value to the reply output variable.
Add 3 more OnMessage activities as part of the Pick activity
Repeat the above steps for other OnMessage activities with other operations

Deploy and test

Monday, January 6, 2020

12c SOA - Oracle Mediator part10 - Java Callout

  • Java Callout is used when we need to have certain validation or want to manipulate the message. We need to implement the oracle.tip.mediator.common.api.IjavaCallout interface to use below defined function for Java Callout.
  • The Java Callout is invoked by the Mediator on a number of times, prior to and after performing the Routing Rule and each of the cases in it. The Java Callout class can implement a number of methods, one for each specific event or stage in the Mediator process. These methods get access to the input message as well as the transformation result. That means that the callout class can inspect, validate, log, audit and even manipulate these messages, their payloads, headers and properties.
We have below methods in the oracle.tip.mediator.common.api.IjavaCallout interface.

Initialize : This method is invoked when the callout implementation class is instantiated for the first time.
preRouting : This method is called before Mediator starts executing the cases. You can customize this method to include validations and enhancements.
preRoutingRule : This method is called before Mediator starts executing any particular case. You can customize this method to include case-specific validations and enhancements.
preCallbackRouting: This method is called before Mediator finishes executing callback handling. You can customize this method to perform callback auditing and custom fault tracking.
postRouting : This method is called after Mediator finishes executing the cases. You can customize this method to perform response auditing and custom fault tracking.
postRoutingRule: This method is called after Mediator starts executing the cases. You can customize this method to perform response auditing and custom fault tracking.
postCallbackRouting: This method is called after Mediator finishes executing callback handling. You can customize this method to perform callback auditing and custom fault tracking.

UseCase 1: Using a postRouting method, the javacallout will log the response in the soa_server.log/out file.


Create a SOA project and open a mediator component
Select Synchronous interface.

Call a synchronous service

Create a Java class
Add oracle.tip.mediator.common.api.IjavaCallout interface

Modify the postRouting method
    public boolean postRouting(CalloutMediatorMessage calloutMediatorMessage,
                               CalloutMediatorMessage calloutMediatorMessage2,
                               Throwable throwable) throws MediatorCalloutException {
        System.out.println("Mediator has invoked Java Callout; executing postRouting");
        String sPayload = "null";
        for (Iterator msgIt = calloutMediatorMessage2.getPayload().entrySet().iterator();msgIt.hasNext(); ) {
          Map.Entry msgEntry = (Map.Entry);
          Object msgKey = msgEntry.getKey();
          if (msgKey.equals("reply")) {
              Object msgValue = msgEntry.getValue();
              sPayload = XmlUtils.convertDomNodeToString((Node) msgValue);
              System.out.println("Mediator sends reply: " + sPayload);
        } //for
        return true;

Select the created class from call out section

Map the request and response

Deploy and test

Sample class for modifying the input request:
public boolean preRouting(CalloutMediatorMessage calloutMediatorMessage) throws MediatorCalloutException {
        System.out.println("Pre routing...");
        String sPayload = "null";
        String sPayload_changed = "null";
        for (Iterator msgIt = calloutMediatorMessage.getPayload().entrySet().iterator();          msgIt.hasNext(); ) {
            Map.Entry msgEntry = (Map.Entry);
            Object msgKey = msgEntry.getKey();
            if (msgKey.equals("request")) {
                Object msgValue = msgEntry.getValue();
                sPayload = XmlUtils.convertDomNodeToString((Node)msgValue);
                try {
                    XMLDocument xmlpayload = XmlUtils.getXmlDocument(sPayload);
                    NodeList node = xmlpayload.getChildNodes();
                    Node item = node.item(0);
                    System.out.println("the value of the request element = " +
                    sPayload_changed = sPayload.replaceAll(item.getTextContent(),
                                                "changed text");
                    XMLDocument xmlpayload_changed =
                    String mykey = "request";
                    System.out.println("Mediator sends request: " +
                } catch (Exception e) {
        return true;

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...