39.3. JOnAS Web Service

39.3.1. Deployment

This web service uses the EJB stateless CruiseManager. To deploy this web service, create the web service deployment descriptor:

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

  <!-- AXIS deployment file for EJB Cruise -->
  <service name="AirService" provider="java:EJB">
   
  <!-- JNDI name specified in jonas-CruiseApp. -->
  <parameter name="beanJndiName"          
             value="ejb/CruiseManager"/>

  <!-- you can use remote interfaces to access the EJB -->        
    <parameter name="homeInterfaceName"   
               value="cruisePack.CruiseManagerHome"/>
    <parameter name="remoteInterfaceName" 
               value="cruisePack.CruiseManager"/>


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

  <typeMapping
    xmlns:ns="urn:AirService/types"
    qname="ns:ArrayOfString"
    type="java:java.lang.String[]"
    serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
    deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  />
  </service>
</deployment>

To deploy this web service, first deploy the web application axis.war and the EJB corresponding to the web service (CruiseManager.jar).

Then, deploy the web service using the Axis client:

jclient org.apache.axis.client.AdminClient 
  -lhttp://localhost:port/context-root-axis.war/servlet/AxisServlet 
   ws_wsdd

39.3.2. Axis Classes Generation

To call a web service, first generate Axis classes. The generated classes will allow a web service to be called using the static method.

For this step, download the file AirService.wsdl corresponding to the SUN web service description or use the URL containing this file.

The use of the command is as follows:

java org.apache.axis.wsdl.WSDL2java <file_name or url>

This command generates four Java files:

CruiseManagerService.java: the service interface

CruiseManagerServiceLocator.java: the service implementation

CruiseManager.java: the endpoint interface

AirServiceSoapBindingStub.java: the stub class.

To call the JOnAS web service, instantiate the service implementation. Then, call the method getAirService() to get the end point interface, and call the appropriate method.

 
AirService_JOnAS.Client.CruiseManagerService cms=
     new AirService_JOnAS.Client.CruiseManagerServiceLocator();

AirService_JOnAS.Client.CruiseManager cmi=cms.getAirService();

Object result=cmi.<method>;

39.3.3. JSP Files

To access the JOnAS web service, copy the JSP files contained in the EJB's web application (Cruises/cruise_WebModule).

The JOnAS web service call must replace the call for each EJB.

39.3.4. Web Application

Finally, create the web application jonas-web.xml. Then, build the web application, which contains:

META-INF/
META-INF/MANIFEST.MF
WEB-INF/
WEB-INF/jonas-web.xml
WEB-INF/lib/
WEB-INF/lib/CruiseManager.jar
WEB-INF/classes/
WEB-INF/classes/AirService_pkg/
WEB-INF/classes/AirService_JOnAS/Client/CruiseManagerService.class
WEB-INF/classes/AirService_JOnAS/Client/AirServiceSoapBindingStub.class
WEB-INF/classes/AirService_JOnAS/Client/CruiseManager.class
WEB-INF/classes/AirService_JOnAS/Client/ \
  CruiseManagerServiceLocator/AirServiceLocator.class
PalmTree.jpg
aboutus.jsp
air_icon.gif
airbook.jsp
airclient.jsp
airdates.jsp
airdone.jsp
airlist.jsp
clear.gif
crubook.jsp
crudone.jsp
cruise_icon.gif
cruises.jsp
flights.jsp
index.jsp
nwcl_banner.gif
nwcl_banner_a.gif
nwcl_styles.css
WEB-INF/web.xml