Tuesday, January 28, 2014

ODL handler configuration through WLST script - Oracle SOA Suite

ODL handler configuration through WLST script - Oracle SOA Suite:

Oracle Fusion Middleware components write diagnostic log files in the Oracle Diagnostic Logging (ODL) format. Log file naming and the format of the contents of log files conforms to an Oracle standard. By default, the diagnostic messages are written in text format.

ODL provides the following benefits:

The capability to limit the total amount of diagnostic information saved. You can set the level of information saved and you can specify the maximum size of the log file and the log file directory.

When you reach the specified size, older segment files are removed and newer segment files are saved in chronological fashion.

Components can remain active, and do not need to be shutdown, when older diagnostic logging files are deleted.

The ODL configuration can be changed from EM console or WLST script.

Below is the WLST script help us to change the ODL handler setting.


domainAdminUserName = "weblogic"
domainAdminPassword = "welcome1"
connect(domainAdminUserName, domainAdminPassword, "t3://localhost:7001")
servers = adminHome.getMBeansByType('Server')
for s in servers:
serverName1 = s.getName()
path = '/Servers/' + serverName1
lh = listLogHandlers()
for l in lh:
lname = l.get('name')
odlfile = folderPath + '/logs/' + serverName1 + '/' + serverName1 + '-' + lname + '-diagnostic.log'
print 'Diagnostic path===>',odlfile
configureLogHandler(target=serverName1,name=lname, path=odlfile)

The other details like maxFileSize,rotationFrequency and retentionPeriod  etc can also be changed through configureLogHandler method.

Executing the script:

$MIDDLEWARE_HOME/Oracle_SOA/common/bin/wlst.sh Configureodlloghandlers.py

Tuesday, January 14, 2014

Polling the Message from WebSphere MQ using MQ Transport in OSB

OSB MQ transport help us to post/receive message from the WebSphere MQ. The MQ transport can be configured to poll the queue for the new messages.

This blog explains how to configure the OSB Proxy Service to poll the Queue for new messages.

Create a OSB Project and Create a Resource of  type MQ Connection.

Provide the MQ Connection details like host name,port number,Queue Manager Name, Channel Name and also provide Connection Pool Size, Connection Timeout and Connection Max Wait. Provide the Static Service Account if User Name/Password is required to connect to MQ and leave the Connection type as default value(tcp mode). Save the connection details.

Create the Business based on the service URL that needs to be invoked after polling the message from the Queue.

Create a proxy Service with the Service Type as Messaging Service.

Select the Request Message Type as XML and Response Message Type as None.

Select the Protocol as mq and provide the Endpoint URI with the queue name and the Queue connection created in the previous step

Configure the polling interval accordingly(Seconds)

Open the Proxy service Message Flow and add a Routing node to the Business Service created in the previous step.


Send  the XML payload to the Queue through HermesJMS or Java, this will initiate the proxy service and intern call the corresponding service with the XML payload(in my case BPEL service)

<ns1:EmployeeRequest xmlns:ns1=\"http://xmlns.oracle.com/JEJBSample/EmployeeDetailService/EmployeeDetailService\">\n" + 
      "<ns1:empNo>987654</ns1:empNo>\n" + 

(Refer the following url to send the message from java to remote queue - http://www.albinsblog.com/2014/01/remote-java-client-to-post-message-to.html#.UtTaKvQW2So )

Monday, January 13, 2014

Remote Java Client to Post the Message to IBM MQ

The below java code will help us to post the message to remote IBM MQ.

package mqclient;
import com.ibm.mq.jms.*;
import javax.jms.*;

public class MQJavaClient {
    public static void main(String[] args)
      try {
       MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
       MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
       MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
       MQQueue queue = (MQQueue) session.createQueue("queue:///DUMMY_Q?targetClient=1");      
       MQQueueSender sender =  (MQQueueSender) session.createSender(queue);
      String message="<ns1:EmployeeRequest xmlns:ns1=\"http://xmlns.oracle.com/JEJBSample/EmployeeDetailService/EmployeeDetailService\">\n" +
      "<ns1:empNo>987654</ns1:empNo>\n" +
       TextMessage textMessage = (TextMessage) session.createTextMessage(message);  
      }catch (Exception e) {

Jar Files Required:


Friday, January 10, 2014

Initiating an OSB Service with Email

Email transport will help us to send/receive emails in OSB. Some cases we may required to initiate the external service based on the email in the user inbox.

The Proxy service polls the Mail Inbox for the new messages and invokes the Business service whenever there is a new message in the Inbox.The polling interval can be specified in the Proxy Service configuration.Here i will explain about invoking the service with the XML message received from the email body.

Create a XSD message structure that will be used by Proxy Service to receive the message

<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified"
<element name="EmployeeRequest">
<element name="empNo" type="string"/>

Create a OSB project and create a Business service that needs to be invoked based on the Email content - Here i am invoking a sample BPEL service with the same XSD structure as input.

Create a Service Account with Static username/password of email user.

Create a Proxy Service with Service Type as Messaging Service

Select the Request Message Type as XML and Response Message Type as None

Select the protocol as email and specify the mail server-host and port in the Endpoint URI.

Configure the Service Account Created in the previous step, specify the polling interval as per requirement, select the Post Read Action as per the requirement and also specify the Download/Archive/Error directories accordingly.

Open the Proxy service Message Flow and add a Routing node to the Business Service created in the previous step.


Send a mail with the XML payload to the configured user, this will initiate the proxy service and intern call the corresponding service with the XML payload(in my case BPEL service)

Tuesday, January 7, 2014

Exposing a OSB Proxy Service as EJB through JEJB transport

The JEJB transport lets you pass Plain Old Java Objects (POJOs) through Oracle Service Bus.To a J2EE client, a JEJB proxy service looks like a stateless session bean. A JEJB proxy service, on receiving the method arguments, passes their XML representation in the pipeline $body variable. POJO arguments are represented as the XML fragment. This XML fragment contains the location of the actual POJO stored in the object repository within the pipeline.

For deployment, Oracle Service Bus automatically packages JEJB proxy services as enterprise archives (EARs) and deploys to weblogic server(OSB Server).

JEJB transport uses the Java Interface to expose as EJB.

Here i will explain exposing the proxy service as EJB and invoking the same through java client by passing/receiving  the java objects and invoking the business service by passing/receiving the XML(Java utility methods will be used to convert Java to XML and XML to Java).The BPEL service invoked will receive the empno and and return back the employee details.

Create a Java interface that will receive/return the Employee object .

package jejbsample;
public interface EmployeeDetails {
    Employee getEmployeeDetails(Employee emp);

package jejbsample;
import java.io.Serializable;
public class Employee implements Serializable{
    private String empName;
    private String empNo;
    private String empDept;
    private String empLoc;  
    public Employee() {

    public void setEmpName(String empName) {
        this.empName = empName;
    public String getEmpName() {
        return empName;
    public void setEmpNo(String empNo) {
        this.empNo = empNo;
    public String getEmpNo() {
        return empNo;
    public void setEmpDept(String empDept) {
        this.empDept = empDept;
    public String getEmpDept() {
        return empDept;
    public void setEmpLoc(String empLoc) {
        this.empLoc = empLoc;
    public String getEmpLoc() {
        return empLoc;

Create a Utility class that will convert the Java to XML and XML to Java.

package javaxmlconverter;
import java.io.InputStream;
import javax.xml.parsers.*;
import jejbsample.Employee;
import org.apache.xmlbeans.*;
import org.w3c.dom.*;

public class JavaXMLConverter {
    public JavaXMLConverter() {
    public static String getEmpRequestXML(Employee emp) {       
        return emp.getEmpNo();
    public static Employee getEmpResponseJava(XmlObject xml) throws Exception{
            Employee emp = new Employee();        
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            InputStream inputStream = xml.newInputStream();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(inputStream);           
            String empName=null ;
            String empNo=null;
            String empDept=null;
            String empLoc=null;            
            NodeList nList = doc.getElementsByTagName("EmployeeResponse");
            for (int temp = 0; temp < nList.getLength(); temp++) {
                Node nNode = nList.item(temp);
                if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                    Element eElement = (Element)nNode;
                     empName =eElement.getElementsByTagName("empName").item(0).getTextContent();
                     empNo =eElement.getElementsByTagName("empNo").item(0).getTextContent();
                     empDept =eElement.getElementsByTagName("empDept").item(0).getTextContent();
                     empLoc =eElement.getElementsByTagName("empLoc").item(0).getTextContent();
        return emp;

Create a jar file based on this classes.

Create a OSB project and load the Jar file created in the previous step to the project.

Create a BusinessService based on the service WSDL.

Create a proxy service and select the Service Type as Transport Typed Service, by default the protocol will be selected as jejb.

Select the EJB Spec Version as 3.0 and select the client jar and the Business Interface accordingly.

Open the Proxy Service Message Flow and edit the Route Node.
Create a Request Actions, Java Callout to the method getEmpRequestXML(input parameter $body/open:getEmployeeDetails/open:arg0/ctx:java-content) from the utility class, this will return the empno from input java object.

Assign the request payload
<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:ns1="http://xmlns.oracle.com/JEJBSample/EmployeeDetailService/EmployeeDetailService">
<ns1:EmployeeRequest> <ns1:empNo>{$empno}</ns1:empNo></ns1:EmployeeRequest> 
</soap:Body>  to the body variable

Create a Response Actions, Java Callout to the method getEmpResponseJava from the utility class, this will return the response employee object as reference(make sure you have selected the option Return Parameter as Reference)

Replace the content of body with the required response structure


While activating the OSB projcet, OSB creates the Stateless session bean(the registered JNDI will be same as Endpoint URI of the Proxy Service ) and bundle the same as ear file and deploys to weblogic server 

Create a java client and invoke the proxy service as EJB

package jejbsample;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;

public class ServiceClient {
    public ServiceClient() {
    public static void main(String[] args) {
                Hashtable<String, String> env = new Hashtable<String, String>();
                env.put(Context.SECURITY_CREDENTIALS, "welcome1");
                InitialContext ctx = new InitialContext(env);

                System.out.println("Initial Context created");
                Employee request=new Employee();

                EmployeeDetails empDetails  = (EmployeeDetails)ctx.lookup("EmployeeDetailsPS#jejbsample.EmployeeDetails");
                 // Employee response=  empDetails.getEmployeeDetails(request);
                catch (Exception e)

Contact Form


Email *

Message *