Home arrow Web Services arrow Page 4 - Using EJBs with Axis

Using EJBs with Axis

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).

Author Info:
By: Sams Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
May 25, 2006
  1. · Using EJBs with Axis
  2. · Using EJBs from Axis
  3. · The Session Bean
  4. · The Deployment Unit
  5. · Exposing the EJBs via Axis

print this article

Using EJBs with Axis - The Deployment Unit
(Page 4 of 5 )

Once the EJBs are written, you should deploy and test them before attempting to Web service–enable them. Typically, the EJBs might already exist. In some circumstances, the EJBs may not offer the right service interface, in which case a layer of stateless session beans can be implemented to offer a clean interface that can then be Web service enabled. The EJBs are packaged in an EJB JAR, which is then packaged in an Enterprise Application aRchive (EAR file) g.

The EJBs must have appropriate XML DDs. The tags containing the deployment information for each bean are shown in the following snippets. Here's the DD fragment for the entity bean:

<entity id="SkatesEntity">
SkatesEntityLocal</local> <ejb-class> com.skatestown.ejb.SkatesEntityBean </ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.String</prim-key-class> <reentrant>False</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>SKATES</abstract-schema-
name> <cmp-field id="pc"> <field-name>productCode</field-name> </cmp-field> <cmp-field id="desc"> <field-name>description</field-name> </cmp-field> <cmp-field id="prc"> <field-name>price</field-name> </cmp-field> <primkey-field>productCode</primkey-field> </entity>

And here's the session bean fragment from the DD:

<session id="SkatesService">
<ejb-local-ref id="entref">
Reference to SkatesEntity
SkatesEntityLocal</local> <ejb-link>SkatesEntity</ejb-link> </ejb-local-ref> </session>

As you'll see from looking at the session bean DD, it includes a reference from the session bean to the entity bean. This is the point at which the "java:comp/env/skateEnt" is defined.

The EJBs are now packaged into a JAR file together with the DD. The JAR contents are as follows:

>jar tf skatesejb.jar

blog comments powered by Disqus

- Dealing with Loose Coupling in a Service-Ori...
- Loose Coupling in a Service-Oriented Archite...
- Safety, Idempotence, and the Resource-Orient...
- The Resource-Oriented Architecture in Action
- Features of the Resource-Oriented Architectu...
- The Resource-Oriented Architecture
- Getting Started with Flex
- Automated Billing and Faxing for the Web
- An Introduction to Web Services
- The Foundations of Web Services: From Novice...
- Web Services Reengineering: Finishing Touches
- Fault Handling with Web Services
- Flow and Web Services
- Process Lifecycles and Web Services
- Business Processes and Web Services

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials