Web Service Interoperability between JOnAS and Weblogic

 

The aim of this document is to show basic usage of web services between JOnAS and Weblogic Server. It assumes that the reader does not need explanation about Axis particular tasks (axis deployment with WSDD, ...). Before deployment in Axis, the reader has to check the deploy.wsdd file in order to ensure that the file matches her machine configuration (jndiURL parameter in particular: <parameter name="jndiURL" value="rmi://localhost:1099"/>).

This document describes two aspects:

  1. Access a web service deployed on JOnAS from an EJB deployed on weblogic server.
  2. Access a web service deployed on Weblogic server from an EJB deployed on JOnAS.

Libraries

JOnAS incorporates all necessary libraries including:

(JAX-M and JAX-R are parts of the Web Services Development Pack from Sun)

Weblogic incorporates all necessary libraries including:

Access a web service deployed on JOnAS from an EJB deployed on Weblogic server

Web Service Development on JOnAS

See also the document How to use Axis with JOnAS which explains how to develop and deploy web services on JOnAS.

EJB Creation on JOnAS

In order to create a web service based on an EJB, you must create first a stateless EJB.
With this EJB you must create a web application (.war) or an application (.ear), that will define an url to access to the Web Service.

WebService Deployment Descriptor (WSDD)

This part explains the deployment descriptor of the web service.
In order to deploy a web service based on an EJB, you must specify different elements in the WSDD.
This WSDD enables to map the web service on an EJB. For this, you must describe the different EJB classes used.

<deployment xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

<!-- AXIS deployment file for HelloBeanService -->
     <service name="WebServiceName" provider="java:EJB">

<!-- JNDI name specified in jonas-EJB.xml -->
      <parameter name="beanJndiName"   value="EJB_JNDI_Name"/>

<!-- use of remote interfaces to access the EJB is allowed but our example uses local interfaces -->
          <parameter name="homeInterfaceName"   value="EJB_Home"/>
          <parameter name="remoteInterfaceName"  value="EJB_Interface"/>

<!-- JNDI properties it may be necessary to modify hostname and port number, protocol name could be changed in accordance with the ORB used  -->

        <!-- for a RMI ORB  -->
        <parameter name="jndiURL"    value="rmi://<url>:<port>"/>
        <parameter name="jndiContextClass"   value="com.sun.jndi.rmi.registry.RegistryContextFactory"/>

<!-- Specify here allowed methods for Web Service access (* for all) -->
        <parameter name="allowedMethods"   value="*"/>

    </service>

</deployment>

The different tags enable to map the web service on different java classes.
In case your web service uses a complex type, you must map this complex type with a java class. For this, two tags may be used:

<beanMapping qName="ns:local" xmlns:ns="someNameSpace" languageSpecificType="java:my.class"/>, this maps the QName [someNameSpace]:[local] with the class my.class.
<typeMapping qname="ns:local" wmlns:ns="someNamespace" languageSpecificType="java:my.class" serializer="my.java.Serializer" deserializer="my.java.DeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>, where Qname [someNamespace]:[local] is mapped with my.class. The serializer used is the class my.java.Serializer and the deserializer used is my.java.DeserializerFactory.

Web Service Deployment on JOnAS

First deploy the web application or application containing the EJB.
Then deploy the web service using Axis client tool:  jclient org.apache.axis.client.AdminClient -hjonasServerHostname -p8080 deploy.wsdd
The web service WSDL is accessible from the url: http://<host>:<port>/<url-servlet>/<webservicename>?wsdl

EJB proxy development for Weblogic Server

This EJB enables to access the web service deployed on JOnAS from Weblogic server.

Generation of web service client class

In order to access to the web service you must generate the client class. For this, use the ant task clientgen.
For example:

<clientgen wsdl="<wsdl_url>" packageName="my.package" clientJar="client.jar" generatePublicFields="True" keepGenerated="True"/>

This command creates 4 classes:

The tool may also generate the java classes corresponding to eventual web service complex types.

Build the EJB

Then in the EJB proxy code you must call the web service using these generated classes.
For example:

         try {
                WSNAME_Impl tsl=new WSNAME_Impl(); // access web service impl
                EJB_endpoint tsp = tsl.getEJB_endpoint(); // access WS endpoint interface
                ComplexType tr=tsp.method(param);
             }  catch (Exception e) {
                e.printStackTrace(System.err);
             };
    

Deploy the EJB on Weblogic Server

Deploy this EJB using the weblogic administration console.

Access a web service deployed on Weblogic server from an EJB deployed on JOnAS

Web Service Development for Weblogic Server

Creation of an application

In order to create a web service, you must first develop the corresponding EJB application. Compile the EJB classes and create a jar file. In order to create the EJB's container, apply the ant task wlappc to the jar file. For example: <wlappc debug="${debug}" source="interface_ws_jonas.jar" classpath="{java.class.path}:interface_ws_jonas.jar".
Then create the ear application containing the web service using the ant task servicegen.

            <servicegen
               destEar="ears/myWebService.ear"
               contextURI="web_services" >
               <service
                   ejbJar="jars/myEJB.jar"
                   targetNamespace="http://www.bea.com/examples/Trader"
                   serviceName="TraderService"
                   serviceURI="/TraderService"
                   generateTypes="True"
                   expandMethods="True" >
               </service>
             </servicegen>

    THE ANT USED IS THE ANT PROVIDED BY WEBLOGIC
 

WebService Deployment

Deploy the webservice using the Weblogic administration console, and deploy the corresponding application.
The WSDL is accessible at http://<host>:<port>/webservice/web_services?WSDL
 

EJB proxy development for JOnAS

This EJB enables to access the web service deployed on Weblogic from JOnAS.

Generation of web service client class

In order to access a web service, you must generate a client class. For this, use the axis tool WSDL2Java <webservice-url-wsdl>.
This command creates 4 classes:

The tool also generates the java class corresponding to the eventual web service complex types.

Build the EJB

Then in the EJB proxy code you must call the web service using this generated class.
For example:

        try {
            WSNAMELocator tsl=new WSNAMELocator();
            WSNAMEPort tsp = tsl.getWSNAMEPort();
            ComplexType tr=tsp.method(param);
            ...
            } catch (Exception e) {
                 e.printStackTrace(System.err);
            };
    

Deploy the EJB on JOnAS

Deploy the EJB using the JOnAS administration console or command.