Read this article if you would like to learn how to use SOAP, WSDL, and the Web services stack with J2EE. The second of three parts, this section focuses on EJBs and Axis. 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).
A word about versions: While J2EE 1.4 has just been released, J2EE 1.3 is still the more commonly used version in real systems at the time of this writing. J2EE 1.4 includes significant Web services support, especially the standards JAX-RPC, JAX-R, and JSR 109 ("Implementing Enterprise Web Services"), as well as improvements specifically targeted at producing WS-I Basic Profile compliance (http://ws-i.org/Profiles/Basic/2003-08/BasicProfile-1.0a.html).
As a result, every J2EE application server will support the following:
A UDDI registry
Calling out to external Web services through JAX-RPC
Hosting Web services using EJBs and servlets
Calling out to UDDI servers
The rest of this chapter is split into three parts. First, we create the EJBs that form the core of the application. This isn't a full tutorial on EJBs, but just a simple EJB application that allows SkatesTown to get going.
Next, we investigate using Web services with an existing J2EE server by using the Apache Axis toolkit. In this section, we assume that there is a running J2EE server such as BEA WebLogic, JBOSS, or IBM WebSphere, and we look at using the Apache Axis framework to connect to EJBs. We're doing this because the SkatesTown developers are familiar with Axis and would like to understand how EJBs fit into the model they already have; and although this is more difficult than the approach in the last part of the chapter, not all application servers support that approach yet.
Finally, we look at how this model is simplified and updated when we utilize new support from J2EE 1.4 to deploy a service directly into an enabled J2EE container. This support (called JSR109) simplifies the model considerably. In this part, we'll use IBM WebSphere as the container, and we'll clearly call out the standard aspects versus the application server–specific aspects. Once J2EE 1.4 is widespread, this will be the standardized approach to using Web services with J2EE, and all J2EE 1.4 application servers will need to support this model.
This last approach is much less work than using Axis, because the tooling and container do much of the work for you; so, if you have a JSR109-enabled container, you may wish to skip trying the Axis approach. However, we recommend reading the section in order to understand the differences between the two approaches and how EJBs fit into the Axis approach.