Pages

Sunday, June 27, 2010

Exposing database artifacts as Web Services without writing any Java code

With the help of the  EclipseLink DBWS framework it is very simple to generate Web Services based on SQL statements, a table or a PL/SQL Procedure.without knowing or writing any java code. The only thing you need to do is to configure the dbws-builder xml and use this in the DBWS generator. The result of this generator can be a WAR archive, which you can deploy on a WebLogic Server.  Because Eclipselink DBWS is part of EclipseLink you don't need to install any libraries on the WebLogic Server and after deployment you can test these Web Services in the WebLogic Console or add some OWSM or WLS WS Security policies. 

First you need to download EclipseLink and unpack the zip. Next step is to set the JAVA_HOME and provide the JDBC Drivers location. Go to the eclipselink\utils\dbws folder and edit the setenv.cmd or setenv.sh file.

set JAVA_HOME=xxxxx\jdk160_18
set DRIVER_CLASSPATH=xxxxx\wlserver_10.3\server\lib\ojdbc6.jar;C:\oracle\MiddlewareJdev11gR1PS2\wlserver_10.3\server\lib\aqapi.jar
You can replace xxxxx with any 10.3.2 or 10.3.3 Middleware home or use a JDeveloper 11g R1 home.

For this blogpost, I will use the emp and dept table of scott demo schema ( Part of the Oracle Database ) and use a PL/SQL package. Here is the code of the package, this packages contains two functions, the first returns the time in the required format and the second return all the departments in a ref cursor.
create or replace package scott_ws is
  function get_current_time(date_format varchar2) return varchar2;

  function get_all_department return SYS_REFCURSOR; 

end scott_ws;
/
create or replace package body scott_ws is

  function get_current_time(date_format varchar2) return varchar2 is
    v_time varchar2(20);
  begin
    if date_format is null then
      return 'empty format';
    end if;
    select to_char(sysdate, date_format) into v_time from dual;
    return v_time;
  
  exception
    when others then
      return 'error';
  end;

  function get_all_department
  return SYS_REFCURSOR 
  is
   dept_recordset SYS_REFCURSOR; 
  begin
    OPEN dept_recordset FOR SELECT * FROM dept;
    return dept_recordset;
  end get_all_department;

end scott_ws;
/

Next step is to configure the dbws-builder xml file. ( Click here for more information about the dbws-builder xml ) The first properties part is necessary information for the DBWS generator. Off course you need to provide the JDBC Driver details. The dataSource property is for the JNDI name of the JDBC Datasource, this need to be created on the WebLogic Server.
<?xml  version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <properties>
    <property name="projectName">scott</property>
    <property name="username">scott</property>
    <property name="password">tiger</property>
    <property name="url">jdbc:oracle:thin:@localhost:1521:orcl</property>
    <property name="driver">oracle.jdbc.OracleDriver</property>
    <property name="dataSource">jdbc/scottDS</property>
    <property name="targetNamespace">http://www.whitehorses.nl/scott</property>
    <property name="logLevel">finest</property>
    <property name="contextRoot">/MyScottServices</property>
  </properties>

  <table catalogPattern="%" tableNamePattern="EMP">
    <sql name="findEmpByDept2" isCollection="true" returnType="empType">
        <text>
          <![CDATA[select * from EMP where DEPTNO like ?]]>
        </text>
       <binding name="DEPTNO" type="xsd:int"/>
    </sql>
  </table> 

  <table catalogPattern="%" tableNamePattern="DEPT"/>

  <sql name="findEmpByDept" simpleXMLFormatTag="employees" xmlTag="employee">
      <text>
         <![CDATA[select * from EMP where DEPTNO like ?]]>
      </text>
     <binding name="DEPTNO" type="xsd:int"/>
  </sql>

  <procedure catalogPattern="scott_ws" 
              schemaPattern="SCOTT" 
              procedurePattern="get_all_department"
               isCollection="true"
               simpleXMLFormatTag="departments"
               xmlTag="department"/>

  <procedure catalogPattern="scott_ws" 
            schemaPattern="SCOTT" 
            procedurePattern="get_current_time"
             simpleXMLFormatTag="scott_ws" 
             xmlTag="time"/>

</dbws-builder>

To expose a table as Web Service you can use this
<table catalogPattern="%" tableNamePattern="DEPT"/>

You can also use a SQL statement with or without any bind variables. Here is it handy to provide the simpleXMLFormatTag and xmlTag attributes.
<sql name="findEmpByDept" simpleXMLFormatTag="employees" xmlTag="employee">
<text>
<![CDATA[select * from EMP where DEPTNO like ?]]>
</text>
<binding name="DEPTNO" type="xsd:int"/>
</sql>

To expose a function in a package I can use this and because this will return all the departments, the isCollection attribute need to be true and here is it also good, to provide the simpleXMLFormatTag and xmlTag attributes.
<procedure catalogPattern="scott_ws"
schemaPattern="SCOTT"
procedurePattern="get_all_department"
isCollection="true"
simpleXMLFormatTag="departments"
xmlTag="department"/>

The last part of this dbws-builder xml is the emp table with inside a SQL statement. This is handy when you want to re-use the emp complex type. In this case I will also use the empType ( table name + Type ) in the SQL statement ( returnType attribute ).

We are ready to generate some Web Services based on this dbws-builder xml.
Go to the eclipselink\utils\dbws folder and start this in a cmd box.
dbwsbuilder.cmd -builderFile scott_emp.xml -stageDir c:\temp\test -packageAs wls scott.war

this will generate a war which can be deployed on WebLogic. you can also use -packageAs jdev or -packageAs eclipse. Then you can include this code in your JDeveloper or Eclipse project.

Go to the Weblogic Console ( http://xxxx:7001/console ) and create the JDBC Datasource ( jdbc/scottDS ) and target this datasource to the right servers.

Go to deployments and click on install, Select your WAR.
After deployment you can click on the application and open the web service
Click on the Test Client to test your WSDL operations.

The last optional step is to configure the security on these web services.  Go to the Configuration /  WS-Policy Tab and select the endpoint.
You can choose for the WS security policies of OWSM or those of Weblogic. To configure OWSM for this Web Service you can use this blogpost.
That's all

Monday, June 14, 2010

Enriching and Forwarding your data with the Spring Component in SOA Suite 11g PS2

Enriching your data with the Oracle ESB or with the Mediator component in SOA Suite 11g can be hard. It works perfectly in a one-way ( fire and forget ) situation, like described in this AMIS guide. With the Patch Set 2 of SOA Suite 11g R1 there is a new supported SOA Suite Component called Spring Component which can do this trick perfectly and no limitations.
In this blogpost you will see how easy it is to use Java in the Spring Component, how you can wire this Component to other Components, Services or References adapters. And off course there is no limition in how many times you can enrich or change the data in the Spring Component.
In this example an Employee request with only a Employee Id is enriched with Employee & Department information and this data is forwarded to a logger Spring Component, a processing Mediator and this data is also returned to the initiator of the request. Here is a overview of all the components and adapters


For this example you need an EJB Session Bean and the Employee and Department JPA Entitiy ( Based on the HR demo Schema ). This EJB Session Bean is also exposed as a Web Service.
The HrReference adapter calls the EJB Session Bean interface and the HrWSReference adapter calls the Web Service Interface of this Session Bean. This Model project is included in the example workspace.

Let's start easy with the SpringLogger Spring component. This component will only do a System out. Drop a Spring Component on the composite xml. This create a empty Spring Context XML. Because the plan is to call this component from a other component you need to create a Service interface. For this component this means you need to create a Java Interface class.
package nl.whitehorses.soa.spring.logger;
public interface ILogger {
  public void log (String componentName, 
                   String instanceId, 
                   String message);
}
Add a service to the SpringLogger Component, this service has the java interface as type.
<sca:service target="logger" name="LogServiceEJB"
      type="nl.whitehorses.soa.spring.logger.ILogger"/>
Next step is to make a implementation of this java interface. This will do the processing ( In this case just a System out println )
package nl.whitehorses.soa.spring.logger;

public class LoggerImpl implements ILogger {
    public LoggerImpl() {
    }

    public void log(String componentName, 
                    String instanceId, 
                    String message) {
      StringBuffer logBuffer = new StringBuffer ();
      logBuffer.append("[").append(componentName).append("] [Instance: ").
          append(instanceId).append("] ").append(message);
      System.out.println(logBuffer.toString());
    }
}
And you can add this implementation to the SpringLogger Component, The target attribute of the service references to the name of this bean.
<bean class="nl.whitehorses.soa.spring.logger.LoggerImpl" name="logger"/>
This spring component is finished and you can work on the Employee Spring Component which will do the enriching and forwarding of the data.
Before you can start with the java interface or implementation, you need to make some entities which will be used in this interface.
The department entity
package nl.whitehorses.soa.entities;

public class Department {
    public Department() {
    }

    private Integer departmentId;
    private String name;


    public void setDepartmentId(Integer departmentId) {
        this.departmentId = departmentId;
    }

    public Integer getDepartmentId() {
        return departmentId;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}
The employee entity with the department attribute.
package nl.whitehorses.soa.entities;

public class Employee {
    public Employee() {
    }

    private Integer employeeId;
    private String  firstName;
    private String  lastName;
    private String  state;
    private Department department;


    public void setEmployeeId(Integer employeeId) {
        this.employeeId = employeeId;
    }

    public Integer getEmployeeId() {
        return employeeId;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getState() {
        return state;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public Department getDepartment() {
        return department;
    }
}
You can now use the employee entity in the java interface class. This interface will be used in the Spring Component Service. The Service has employeeId as parameter and will return the employee entity.
package nl.whitehorses.soa.spring.enrichment;

import nl.whitehorses.soa.entities.Employee;
public interface IEmployee {

  public Employee enrichEmployee(Integer employeeId, 
                                 String  componentName, 
                                 String  instanceId);

}

And the implementation. In the enrichEmployee method you will do all the enrichment and forwarding. We will continuous change this method when we wire all the reference adapters.
package nl.whitehorses.soa.spring.enrichment;

import nl.whitehorses.soa.entities.Employee;

public class EmployeeEnrichmentImpl implements IEmployee {
    public EmployeeEnrichmentImpl() {
    }

    public Employee enrichEmployee(Integer employeeId, 
                                   String  componentName, 
                                   String  instanceId) {
        Employee employee = new Employee();
        return employee;
    }

}
Drop a new Spring Component to the Composite, add a Service and a Bean based on these java classes in the Spring Context XML.
<beans>
   <sca:service target="employee" 
                name="EmployeeServiceEJB"
                type="nl.whitehorses.soa.spring.enrichment.IEmployee"/>

   <bean class="nl.whitehorses.soa.spring.enrichment.EmployeeEnrichmentImpl" 
         name="employee">
   </bean>
</beans>
Wire the reference of the SpringEmployeeEnrichment Component to the service of the SpringLogger Component.
JDeveloper will add a reference in the SpringEmployeeEnrichment Spring Context to the SpringLogger Component.
<beans>

   <sca:service target="employee" name="EmployeeServiceEJB"
      type="nl.whitehorses.soa.spring.enrichment.IEmployee"/>

   <bean class="nl.whitehorses.soa.spring.enrichment.EmployeeEnrichmentImpl" 
         name="employee">
   </bean>

   <sca:reference type="nl.whitehorses.soa.spring.logger.ILogger"
                  name="LogServiceEJB"/>
</beans>
This reference need to be injected to the EmployeeEnrichmentImpl class. Add a property to the bean with a reference to the SpringLogger service.
<bean class="nl.whitehorses.soa.spring.enrichment.EmployeeEnrichmentImpl" 
      name="employee">
   <property name="loggerReference"   
             ref="LogServiceEJB" />
</bean>
Add the loggerReference variable ( use the ILogger interface and this must match with the property name of the Spring Bean ) to EmployeeEnrichmentImpl and generate the Accessors. Spring will inject the ILoggerImpl to this variable. In the enrichEmployee method you can call the log method and pass on the parameters.
package nl.whitehorses.soa.spring.enrichment;

import nl.whitehorses.soa.entities.Employee;
import nl.whitehorses.soa.spring.logger.ILogger;

public class EmployeeEnrichmentImpl implements IEmployee {
    public EmployeeEnrichmentImpl() {
    }

    private ILogger loggerReference;

    public Employee enrichEmployee(Integer employeeId, 
                                   String  componentName, 
                                   String  instanceId) {
        // log the request.
        loggerReference.log(componentName, instanceId, "Enrich employee: "+employeeId);
        Employee employee = new Employee();

        return employee;
    }
   
    public void setLoggerReference(ILogger loggerReference) {
        this.loggerReference = loggerReference;
    }

    public ILogger getLoggerReference() {
        return loggerReference;
    }
}

The next step is to expose the Service of the Spring Component. Drag the service to the Exposed Services part of the composite. So you can invoke this service.
You can now choose to expose this as an EJB or a Web Service. Choose Web Service so you can invoke this service in the Enterprise manager.
With this as result.
This is not the best way to expose this Spring Component Service, every change in the java interface will lead to a different WSDL, so let's add a Mediator with an Employee XML Schema to solve this. Now you can change the WSDL or the Java Interface of the Spring Service and only need to update the transformation in the routing rule of the Mediator.
Wire the Mediator to the Spring Component service and add the request and response transformations ( in the routing rule )

Now we can return to the Enrichment part by adding a EJB and Web Service reference adapter and wire this to the Spring component.
First we use the EJB adapter to lookup the employee. You need to change the Implementation by adding a variable based on the Remote Interface of the EJB Session Bean. Add the Service Interface jar of the EJB Session Bean to the dependency of the SOA Project and also put it in the SCA-INF/lib folder. The enrichEmployee method will invoke this EJB and converts the result to a local employee entity.

package nl.whitehorses.soa.spring.enrichment;

import nl.whitehorses.soa.entities.Employee;
import nl.whitehorses.soa.model.hr.entities.Employees;
import nl.whitehorses.soa.spring.logger.ILogger;
import nl.whitehorses.soa.model.hr.services.HrModelSessionEJB;


public class EmployeeEnrichmentImpl implements IEmployee {
    public EmployeeEnrichmentImpl() {
    }

    private ILogger loggerReference;
    private HrModelSessionEJB hrModelReference;

    public Employee enrichEmployee(Integer employeeId, 
                                   String  componentName, 
                                   String  instanceId) {

        // log the request.
        loggerReference.log(componentName, instanceId, "Enrich employee: "+employeeId);

        // get the employee from the SOA Suite Reference
        Employees emp = hrModelReference.getEmployeesFindOne(employeeId);
        
        Employee employee = new Employee();
        employee.setEmployeeId(emp.getEmployeeId().intValue());
        employee.setFirstName(emp.getFirstName());
        employee.setLastName(emp.getLastName());
        employee.setState("logged");

        return employee;
    }

   
    public void setLoggerReference(ILogger loggerReference) {
        this.loggerReference = loggerReference;
    }

    public ILogger getLoggerReference() {
        return loggerReference;
    }

    public void setHrModelReference(HrModelSessionEJB hrModelReference) {
        this.hrModelReference = hrModelReference;
    }

    public HrModelSessionEJB getHrModelReference() {
        return hrModelReference;
    }

}
Add a new Spring Context Reference based on this Remote interface of the EJB Session Bean. Also add a new property to the Spring Bean which matches with the variable in the Implementation.
<beans>

   <sca:service target="employee" 
                name="EmployeeServiceEJB"
                type="nl.whitehorses.soa.spring.enrichment.IEmployee"/>

   <bean class="nl.whitehorses.soa.spring.enrichment.EmployeeEnrichmentImpl" 
         name="employee">
      <property name="loggerReference"   ref="LogServiceEJB" />
      <property name="hrModelReference"  ref="HrServiceEJB" />
   </bean>

   <sca:reference type="nl.whitehorses.soa.spring.logger.ILogger"
                  name="LogServiceEJB"/>

   <sca:reference name="HrServiceEJB"
                  type="nl.whitehorses.soa.model.hr.services.HrModelSessionEJB"/>
</beans>
Add a new wire for the EJB Reference Adapter by Dragging the not used reference of the Spring Component to the external references of the Composite.
Choose the EJB option.
With this as result.
Open the EJB Reference Adapter and update the JNDI name. ( I deployed the EJB Session Bean on the Soa Suite Server)
The EJB Reference Adapter is finished and wired to the Spring Component.

The next step is to add a Web Service Reference to the Spring Component, I will use this WS to lookup the department of the employee.When you want to use a Web Service in the Spring Component you need to add the Web Service Reference adapter first ( Because I don't have a Web Service Client Proxy )
Add a Web Service Reference Adapter to your Composite.
Wire the WS to the Spring Component Reference.
JDeveloper will generate a WS proxy client and add a Reference to the Spring Context.
<sca:reference type="nl.whitehorses.soa.model.hr.services.HrSessionBeanService"
                      name="HrWSReference"/>
And add a property to this reference on the Spring Context bean. Change the Spring Component implementation so you can invoke the Web Service to lookup the department.
package nl.whitehorses.soa.spring.enrichment;

import nl.whitehorses.soa.entities.Department;
import nl.whitehorses.soa.entities.Employee;
import nl.whitehorses.soa.model.hr.entities.Employees;
import nl.whitehorses.soa.spring.logger.ILogger;
import nl.whitehorses.soa.model.hr.services.HrModelSessionEJB;
import nl.whitehorses.soa.model.hr.services.HrSessionBeanService;

public class EmployeeEnrichmentImpl implements IEmployee {
    public EmployeeEnrichmentImpl() {
    }

    private ILogger loggerReference;
    private HrModelSessionEJB hrModelReference;
    private HrSessionBeanService hrWSModelReference;

    public Employee enrichEmployee(Integer employeeId, 
                                   String  componentName, 
                                   String  instanceId) {

        // log the request.
        loggerReference.log(componentName, instanceId, "Enrich employee: "+employeeId);

        // get the employee from the SOA Suite Reference
        Employees emp = hrModelReference.getEmployeesFindOne(employeeId);
        
        // get the department from the WebLogic SCA Reference
        nl.whitehorses.soa.model.hr.services.Departments dept = hrWSModelReference.getDepartmentsFindOne(emp.getDepartmentId());
        
        Department department  = new Department();
        department.setDepartmentId(dept.getDepartmentId().intValue());
        department.setName(dept.getDepartmentName());
        
        Employee employee = new Employee();
        employee.setEmployeeId(emp.getEmployeeId().intValue());
        employee.setFirstName(emp.getFirstName());
        employee.setLastName(emp.getLastName());
        employee.setDepartment(department);
        employee.setState("logged");

        return employee;
    }

   
    public void setLoggerReference(ILogger loggerReference) {
        this.loggerReference = loggerReference;
    }

    public ILogger getLoggerReference() {
        return loggerReference;
    }

    public void setHrModelReference(HrModelSessionEJB hrModelReference) {
        this.hrModelReference = hrModelReference;
    }

    public HrModelSessionEJB getHrModelReference() {
        return hrModelReference;
    }

    public void setHrWSModelReference(HrSessionBeanService hrWSModelReference) {
        this.hrWSModelReference = hrWSModelReference;
    }

    public HrSessionBeanService getHrWSModelReference() {
        return hrWSModelReference;
    }

}

The last part is to connect a Mediator to the Spring Component and pass on the Employee entity so you can for example write this object to a file or insert the employee in a table.
Add a Mediator Component to the Composite and use the Define Interface Later Template.
Create a new Java Interface for this Mediator with the entity you want to pass on.
package nl.whitehorses.soa.spring.enrichment;

import nl.whitehorses.soa.entities.Employee;

public interface IEmployeeMediator {
    
    public void processEmployee ( Employee emp );
}
Change the Spring Component xml, add the reference and the property on the bean
<beans>

   <sca:service target="employee" name="EmployeeServiceEJB"
      type="nl.whitehorses.soa.spring.enrichment.IEmployee"/>

   <bean class="nl.whitehorses.soa.spring.enrichment.EmployeeEnrichmentImpl" 
         name="employee">
      <property name="loggerReference"   ref="LogServiceEJB" />
      <property name="hrModelReference"  ref="HrServiceEJB" />
      <property name="hrWSModelReference"  ref="HrWSReference" />
      <property name="mediatorReference" ref="EmployeeMediator" />
   </bean>

   <sca:reference type="nl.whitehorses.soa.spring.enrichment.IEmployeeMediator"
                  name="EmployeeMediator"/>

   <sca:reference type="nl.whitehorses.soa.spring.logger.ILogger"
                  name="LogServiceEJB"/>

   <sca:reference name="HrServiceEJB"
                  type="nl.whitehorses.soa.model.hr.services.HrModelSessionEJB"/>

   <sca:reference type="nl.whitehorses.soa.model.hr.services.HrSessionBeanService"
                  name="HrWSReference"/>
</beans>
Change the implementation for the Mediator
package nl.whitehorses.soa.spring.enrichment;

import nl.whitehorses.soa.entities.Department;
import nl.whitehorses.soa.entities.Employee;
import nl.whitehorses.soa.model.hr.entities.Employees;
import nl.whitehorses.soa.spring.logger.ILogger;
import nl.whitehorses.soa.model.hr.services.HrModelSessionEJB;
import nl.whitehorses.soa.model.hr.services.HrSessionBeanService;

public class EmployeeEnrichmentImpl implements IEmployee {
    public EmployeeEnrichmentImpl() {
    }

    private ILogger loggerReference;
    private HrModelSessionEJB hrModelReference;
    private HrSessionBeanService hrWSModelReference;
    private IEmployeeMediator mediatorReference;

    public Employee enrichEmployee(Integer employeeId, 
                                   String  componentName, 
                                   String  instanceId) {

        // log the request.
        loggerReference.log(componentName, instanceId, "Enrich employee: "+employeeId);

        // get the employee from the SOA Suite Reference
        Employees emp = hrModelReference.getEmployeesFindOne(employeeId);
        
        // get the department from the WebLogic SCA Reference
        nl.whitehorses.soa.model.hr.services.Departments dept = hrWSModelReference.getDepartmentsFindOne(emp.getDepartmentId());
        
        Department department  = new Department();
        department.setDepartmentId(dept.getDepartmentId().intValue());
        department.setName(dept.getDepartmentName());
        
        Employee employee = new Employee();
        employee.setEmployeeId(emp.getEmployeeId().intValue());
        employee.setFirstName(emp.getFirstName());
        employee.setLastName(emp.getLastName());
        employee.setDepartment(department);
        employee.setState("logged");
        
        mediatorReference.processEmployee(employee);

        return employee;
    }

   
    public void setLoggerReference(ILogger loggerReference) {
        this.loggerReference = loggerReference;
    }

    public ILogger getLoggerReference() {
        return loggerReference;
    }

    public void setHrModelReference(HrModelSessionEJB hrModelReference) {
        this.hrModelReference = hrModelReference;
    }

    public HrModelSessionEJB getHrModelReference() {
        return hrModelReference;
    }


    public void setHrWSModelReference(HrSessionBeanService hrWSModelReference) {
        this.hrWSModelReference = hrWSModelReference;
    }

    public HrSessionBeanService getHrWSModelReference() {
        return hrWSModelReference;
    }

    public void setMediatorReference(IEmployeeMediator mediatorReference) {
        this.mediatorReference = mediatorReference;
    }

    public IEmployeeMediator getMediatorReference() {
        return mediatorReference;
    }
}
Add a wire between the not used reference of the Spring Component and the service of the Mediator.

At last add a File or a Database Adapter to the Composite and wire this to this Mediator.

That's all.

Here is the example workspace.

Thursday, June 3, 2010

JEJB Transport and manipulating the Java Response in OSB 11g

With the JEJB Transport you are able to pass POJO's through an OSB Proxy or Business Service( for the outside world it behaves like a remote EJB). JEJB Transport works like the EJB Transport but the request and response objects are not translated to XML so you can't use XQuery etc. To make things not too hard, OSB 11g makes a XML presentation of the request method and its parameters, which you can use in the Proxy Service.
An example of a Remote interface request method
<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <ns:getEmployeesFindByKey xmlns:ns="http://www.openuri.org/">
    <ns:arg0>199</ns:arg0>
  </ns:getEmployeesFindByKey>
</soap:Body>  
Returning a java response message can be easy and difficult. The easy way is to use the same Java Interface in the Proxy and Business Service, then you don't have to do anything ( the BS will pass the result POJO to the Proxy, which returns it to the EJB client). This can be handy for logging the requests or use the OSB server as an EJB proxy.
An other use case can be, that you want to manipulate the response ( Enrichment ) or want to replace the EJB by Web Services. Thne you don't need to change the Applications which uses these remote EJB's.
In this blogpost I will show you how you can achieve this with a Java CallOut in the response pipeline.
Here is an example of a JEJB response.
<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <ns:getEmployeesFindByKeyResponse xmlns:ns="http://www.openuri.org/">
    <ns:return>
      <con:java-content ref="jcid:-15bb3fe4:128fee47f9f:-7f96"
                        xmlns:con="http://www.bea.com/wli/sb/context"/>
    </ns:return>
  </ns:getEmployeesFindByKeyResponse>
</soap:Body>  
Because the response is a java object you can't see the response. The only thing you can do is to pass the java object ( con:java-content element ) to a Java CallOut parameter and in this static method you can do for example a System printout
Before I start you need to know the basics about the EJB and JEJB Transport so please read my previous blogpost and then continue.

This is a overview picture what  I will do in this blogpost.
It starts with the EJB client which looks up the Remote EJB of the Proxy Service and calls the getEmployeesFindByKey and getEmployeesFindAll method.
The Proxy Service has a JEJB Transport with a Remote Interface and has a Routing Table for the two interface methods. In case of the getEmployeesFindAll method the Proxy calls a HTTP Business service and with the getEmployeesFindByKey method it calls a JEJB Business Service.
The HTTP Business Service call a Rest Service on the Oracle XmlDB which returns all the employees in XML.
The JEJB Business Service call a remote EJB on a Weblogic Server this returns an Employee Entity.
The result of these two Business Service will be handled by the Java CallOut. In case of the getEmployeesFindByKey method the Java CallOut changes the email address of the Employee. The result of the HTTP Business Service is a XML with employees so the Java CallOut needs to convert these Employees to a List of Employee Entities

Here is the Message Flow of the Proxy Service. The Routing Table reads the operation variable. 
This is the Java Class with the static method which will be used in the Java CallOut. I will be using the static employeeReference method. This method has 3 parameters, the first operation parameter is important to determine what kind of conversion I need to do. The Direction parameter is used for logging and the body parameter contains the response of the Business Service. This will be converted to Employee Entities. For XML to Java I will be using JAXB.
package nl.whitehorses.hr.ejb.services;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import nl.whitehorses.hr.ejb.entities.Employees;
import nl.whitehorses.osb.model.jaxb.EMPLOYEES;

import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;

public class EmployeeCon {

  public EmployeeCon() {
  }

  public static Object employeeReference(String operation, String direction, Object body)
throws JAXBException {  
      System.out.println(direction+" operation "+operation); 

      if ( operation.equalsIgnoreCase("getEmployeesFindByKey") ) {

         System.out.println("body input class: "+body.getClass().getName());
         Employees employee = (Employees)body;
         employee.setEmail("edwin@edwin.nl");
         return employee;

      } else if ( operation.equalsIgnoreCase("getEmployeesFindAll") ) { 

          System.out.println("body input class: "+body.getClass().getName());
          XmlAnyTypeImpl employeesXml = (XmlAnyTypeImpl)body;
        
          JAXBContext jaxbContext = 
JAXBContext.newInstance ("nl.whitehorses.osb.model.jaxb");
          Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
          EMPLOYEES employees2 =
(EMPLOYEES)unmarshaller.unmarshal(employeesXml.newInputStream());

          List<Employees> employees = new ArrayList<Employees>();
          for ( EMPLOYEES.ROW item : employees2.getROW() ) {
              Employees employee = new Employees();
              employee.setEmployeeId(item.getEMPLOYEEID().longValue());  
              employee.setFirstName(item.getFIRSTNAME());  
              employee.setLastName(item.getLASTNAME());  
              employee.setEmail(item.getEMAIL()); 
              if ( item.getCOMMISSIONPCT() != null ){
                employee.setCommissionPct(item.getCOMMISSIONPCT().doubleValue());
              }
              if ( item.getDEPARTMENTID() != null) {
                employee.setDepartmentId(item.getDEPARTMENTID().longValue());
              }
              employee.setJobId(item.getJOBID());  
              employee.setPhoneNumber(item.getPHONENUMBER()); 
              if ( item.getSALARY() != null ){
                employee.setSalary(item.getSALARY().doubleValue());
              }

              employees.add(employee);
          }
          return employees;
      }    
      return body;
  }
    
}
First Import the Java CallOut jar into your OSB Project. This must contain the Class with the static method and the Employee Entity.  
Lets start with the easy one ( the getEmployeesFindByKey method) by adding a Java CallOut to the response pipeline. Use the $operation variable for the operation parameter and the ctx:java-content element for the body parameter.The return of the method will be copied to the $result variable.
Because of the JEJB Business Service ( returns the right body content ) I only need to replace the original java content with the result variable.

The getEmployeesFindAll method is a bit different because it uses the HTTP Business Service which returns a body which is not compatible with the JEJB Trasnport. So the body parameter of the Java CallOut has a different expression which matches with the response of the HTTP Business Service.
You need to assign a new JEJB Transport body to the $body variable
The expression of the Assign
That's all and now you can lookup the Remote EJB on the OSB Server and call one of the available methods.