Monday, 13 January 2014

EJB and JEJB Transport in OSB

What is EJB/JEJB Transport:

  • The EJB transport is only available for business services whereas the JEJB transport can be used both on a proxy service as well as for business services.
  • EJB protocol enables us to create a business service which doesn’t stands for a SOAP / HTTP of File service, but for a remote EJB. This allows us to let our OSB clients or our own composite proxy services to communicate with EJBs with a simple SOAP xml message.
  • JEJB protocol allows us take POJOs and make them available as they were EJBs. Here, the XML interface we will expose will only contain a reference to a Java object, and not its XML content. Introduced in OSB 11g.
  • EJB Transport Uses Java Webservices Framework to invoke remote EJBs.
  • JEJB Transport uses an RMI serialization /deserialization cycle and passes Plain old Java Objects(POJO)directly through the OSB to the remote EJBs.
  • Using JEJB transport we can export a proxy service as a stateless session bean.
JEJB Transport Advantages:


  • JEJB Transport Supports both Inbound and Outbound whereas EJB supports only Outbound.
  • JEJB doesn't convert Java objects to Xml Representation.

Example::
TO DO.
1.Create an EJB project and sample test client for that session bean.
2.Import Client Jar to Osb.
3.Create JNDI provider in osb.
4.Create Business service.
5.Create Proxy service.


1.Create an EJB Project:

               Note:providing brief notes as most of SOA developers familiar to work with EJBs  

    • Create a new generic application namely”OsbEjbSampleApplication” in JDEV.
    • In Project Page select EJB technology from available to Selected.
    • Select Entities from table
    • And Click finish.Connect to application server datasource connection as we have application server datasource inWLS.
    • Add a new connection with your db credentials to select table.
    • Enter entity name and accept defaults and say finish.
    • Here my jdbc name is “jdbc/DB/MyDatabase_new ” that I have created in WLS.Entity has created.Now go to persistant.xml..modify the jdbc name to correct jdbc name that we have created in WLS.Here my jdbc name is “jdbc/DB/MyDatabase_new ” that I have created in WLS.
    • Create session bean and expose local and remote interfaces with selected methods.
    • Create Deployment profiles:
                        1.Go to project properties -->select deployment ,click new.
                        2.Select Deployment.and create two deployment profiles..as
                           EJB--JAR deployment profile.
                           Client JAR deployment profile. 
                     
                        3..Right click on Project-->Client JARDeploy-->>Deployed to JAR.(we will use this Client jar file later in osb)
                        4.Rightclick on project-->EJBJARdeploy -->Application server
    • Create Sample java client by right clicking on our session bean.
    • open this client file right click on this file and Run it to test our web service.
    • copy the Jndi name from client class.(this is EJB bean JNDI name)
      OsbEjbApp-OsbEjbPro-osbEJbSession#osbejbpro.osbEJbSession”:


    2.Import Client Jar to OSB

    • Create JAR deployment profile for client project.

    • Deploy client Project to JAR profile.


    • click next..observe the archive file output file path of this Jar file..We need to import this Jar file into OSB in next step..

    • Login to sbconsole.Create session -->Project Explorer-->create Anew Project For this EJB transport-->Create Resource->Utility/JAR.
    • Enter Name for Client Jar file in Osb-->click on Choose file-->navigate to Output archive location which we have noted in previous step(Our Jdev Client project JARdeployed path)-->select the Jar file and click on save.
    3.Creating JNDI provider in OSB
    • Login to osb console(if not already logged in) and Create Session.go to SytemAdmistrator.







    • Click on JNDI Providers under Global Resources and to add our new JNDI provider click on Add.It will display new window for JNDI provider
    •                   enter values
                               NAME:MYJNDIProvider(your JNDI name)
                               Provider URL :http://localhost:7001(server URL where your weblogic server is running)
                               Uname/Pwd::weblogic/welcome1
                               enable java cache
    • Save it.
    4.Creating Business service
    •  Go to create resource-->Business services.
    • Enter Name for your business service and select Transport typed service  as Service type and click next.
    • In the Transport Configuration Screen Select Protocal as JEJB and enter END Point URI asjejb:<jndi_provider_name>:service_name ” format.


    Note: Here service name is the JNDI name that we have copied in JDEV for Client Project.

    Here END point URI:(Please don't include any spaces after : (colon).It will raise an error like it is invalid URI)

    jejb:MyJNDIProvider:OsbEjbApp-OsbEjbPro-osbEJbSession#osbejbpro.osbEJbSession
    • click on ADD.

    • click next..It will navigate TO JEJB Transport Configuration.
                      EJB Spec Version:3.0
                      Client Jar:select the client Jar file That we have imported earlier select it and submit.





    • Business interface: remote session bean(here by default it has selected my remote session bean)
    • Methods:I have only one method in my EJB..
    • Finally our BS looks like this..Save it.
    5.Creating Proxy service

    Note:
    We can create Proxy service directly in osb console..Or we can Export that project from Console to local system(whatever the location we want..it exports entire project as a jar file).And in Eclipse IDE create config project and OSB Project.Inside the OsbProject we can import this Jar file and we will create Proxy service for this.
    Eclipse IDE is very easy to develop message flow for Proxy service.So I imported the project into Eclipse and will create Proxy here.

    NOTE:
    While Exporting project from console to local select “Export Resources” instead of“ExportProjects” because Export resources will export all the dependent files for the selected project like with JNDI Provider also.Other wise eclipse will throw error like missing JNDI provider.

    My eclipse looks like this.
    • Right click on Project -->New-->Proxy service.
    • Select Project and enter Proxy service name and click finish.

    • Select Transport Typed Service in service type.


    • Select JEJB and leave the Endpoint URI as it is and click Next.
     

    • JEJB Transport Configuration:
    • select EJB 3.0 spec and select the Same Client Jar file that we have selected for  BS.






    save your proxy and test them to see our ejb methods are working or not


    No comments:

    Post a Comment

    test