This article shows you how to deploy an EJB application, and more. Picking up where the previous article left off, it is the third of three parts. It is excerpted from chapter 7 of the book Building Web Services with Java: Making sense of XML, SOAP, WSDL, and UDDI, written by Steve Graham et al. (Sams; ISBN: 0672326418).
Deploying an EJB Application - Configuring Axis to Invoke the SkatesService Session Bean (Page 2 of 4 )
In this section, we describe how to configure the Axis server to enable Web service access to your application. Having deployed the application, you need to set up the EJB provider to be able to invoke the SkatesService bean. This means creating a WSDD that contains the relevant information.
Figure 7.4 Apache Axis homepage
Figure 7.5 Axis Happiness page
If Axis was running on a separate server, you would also need to ensure that the J2EE.JAR library and the client stubs for the SkatesService bean were in the Axis classpath. The client stubs are produced as part of the deployment process; usually, the deployed EJB JAR file will contain them. However, by deploying Axis and the EJBs as part of the same enterprise application, the J2EE application server ensures that the EJB client code is available to the Axis Web application. This makes life much easier.
Before running the following commands, create and move to a new directory. The first aim is to create a WSDL file from the SkatesService remote interface. In order to do this, you must run the Apache Java2WSDL tool. It needs both the EJB-JAR file (skatesejb.jar) and the J2EE class library (j2ee.jar):
In order to help deploy this file, you can now run the WSDL2Java tool. This tool creates a deploy.wsdd deployment XML file for Axis that will act as a good starting point; it also creates code with which to call the service. However, the deploy.wsdd file is designed for use with a standard Java class, so you must modify it to work with your EJB application:
The bold sections in Listing 7.5 indicate the incorrect parts of the generated WSDD file. The provider type is java:EJB instead of Java:RPC, and instead of a className parameter, the provider requires beanJndiName and homeInterfaceName parameters, as shown here:
If you pull up a browser and browse the same servlet at http://server:port/axis/servlet/AxisServlet, you should see the SkatesService listed, as shown in Figure 7.6. You can click (wsdl) to view the WSDL.
Figure 7.6 SkatesService listing in the Axis admin page
To test the service, you need to generate a simple command-line client. To do so, create a new directory and rerun WSDL2Java, but this time to generate client objects: