Apache Axis and EJB
This article shows J2EE developers how to use Apache Axis from the IBM ETTK (Emerging Technologies Toolkit) to make any Enterprise JavaBean (EJB) component into a Web service that will run on any application server.
This tutorial shows J2EE developers how to use the IBM ETTK (Emerging Technologies Toolkit) to make any Enterprise JavaBean (EJB) component into a Web service that will run on any application server.
Do you currently use EJB technology? Have you ever wondered how to expose an EJB component as a Web service no matter what your application server is? This tutorial shows how to use the ETTK and Axis to convert a local and remote EJB component into a Web service. I will use a subcomponent of the ETTK called Axis, a SOAP client implementation originally hosted by the Apache Software Foundation.
The ETTK implements the Web services architecture and provides a set of tools to create, locate and invoke Web services. It includes the following tools:
UDDI4J API allows developers to perform save, delete, find, and get operations against a UDDI registry.
UDDI4J-WSDL API allows developers to perform publish, unpublish, and find operations against a UDDI registry.
WSDL4J allows developers to programmatically read and work with WSDL documents.
WSDLdoc allows developers to automatically generate documentation from WSDL files similar to JavaDoc.
WSIL4J allows developers to programmatically read and work with WSIL documents.
Axis RC1 allows a developer to generate Web services WSDL definitions from Java code and generate Java proxy code from a WSDL definition. Axis is also the transport engine for Web services.
Sample services including Accounting, Contract, Metering, Service Desk etc.
Demos and tutorials to illustrate key Web service concepts.
And much more...
If you are serious about Web services then you have to check out IBM's ETTK!
The primary focus of this tutorial is developing EJB-based Web services with Axis. Axis provides support for turning EJB components into Web services and is included with the ETTK.
What this tutorial covers page
This tutorial covers turning EJB components into Web services and has two step-by-step examples. The first example uses all primitive types with one simple EJB component. The second example uses a SessionBean that talks to several EJB components and returns complex types. All examples ship with a set of Ant build scripts so you can easily create your own custom solutions by reusing the sample build files.
This tutorial assumes you have a working knowledge of Java technology and EJB technology. In-depth knowledge of EJB components, Web services, and Ant are helpful but not required to understand the key concepts. Ant is used to build and deploy the example applications. Reference to introductory material on Ant, Java technology, J2EE, Web services, XML, and EJB components are provided in throughout the tutorial and at the references section at the end of this tutorial.
The source code in the tutorial has been tested with Resin EE application server.
The applications should be easy to port to other J2EE-compliant application servers like IBM WebSphere or JBoss. Please check back at my site for ports to other application servers (see Resources).
I typically get examples from people working with other application servers, and then I put them up on my site (see Resources).
I used the Eclipse framework to create the examples in this tutorial. The examples are easiest to run by downloading Eclipse 2.1 or higher and a J2EE application server plug-in for Eclipse. Eclipse has excellent support for Ant, which facilitates running the Axis and XDoclet Ant tasks right from the IDE environment.
If you are new to Ant, please read this sample chapter from Mastering Tomcat on Developing Web Components with Ant (written by yours truly). Just read the sections on Ant development for now.
Also note that the Ant scripts can use XDoclet. You will not need to use this functionality, but, in case you decide to, please refer to the developerWorks tutorial, "Enhance J2EE component reuse with XDoclet" (see Resources).