O'Reilly logo

Java Web Services in a Nutshell by Kim Topley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using EJBs to Implement Web Services

So far, you have seen how to implement a web service and arrange for it to be hosted by a servlet in a web container. J2EE 1.4 extends this model by allowing you to implement web services as stateless session beans in the EJB container or, if you want to view it another way, to advertise the remote interface of an existing stateless session bean as a web service, provided that the interface methods meets the requirements of a JAX-RPC service endpoint interface.

Web Service Session Bean Requirements

Session beans typically have a combination of the following:

  • A remote interface that contains the service methods that remote clients can invoke. This interface is required to extend javax.ejb.EJBObject.

  • A local interface that contains the methods available to clients that reside with the session bean. This may be the same set of methods as those in the remote interface, but this is not required. The local interface extends javax.ejb.EJBLocalObject.

  • A home interface that remote clients use to manage their view of the lifecycle of the session bean, including obtaining an instance of it and releasing it when it is no longer required. The home interface must extend javax.ejb.EJBHome and is required to exist if the session bean provides a remote interface.

  • A local home interface, which is the equivalent of the home interface for clients that are local to the bean and extends javax.ejb.EJBLocalHome. The local home interface is required only if the bean provides ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required