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:
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:
See also the document How to use Axis with JOnAS which explains how to develop and deploy web services 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.
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.
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
This EJB enables to access the web service deployed on JOnAS from Weblogic server.
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.
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 this EJB using the weblogic administration console.
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
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
This EJB enables to access the web service deployed on Weblogic from JOnAS.
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.
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 using the JOnAS administration console or command.