Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Stateless EJBs for Java Web services

It is recommended that we use stateless EJBs for implementation of Java Web services. What are the logical reasons behind that? How do I manage state when using EJB as implementation for Java Web service? Are there stateless and stateful Web services? And how do you implement a Web service using stateful EJBs?
When discussing EJBs and Web services, stateless EJBs are usually recommended for building Web services. This is for a couple of reasons:
1) At present, Web services built around published standards are stateless
2) Stateless EJBs are usually recommended by the EJB community for encapsulating business logic.

Since current standards for Web services do not address maintaining state, you must use your own mechanism for maintaining state, such as proprietary cookies.

SOAP is currently the most widely discussed technology for Web service implementation and transport. Thus, any technology used to implement the logic that a service will expose, must, for all practical purposes, support SOAP. This means that whether or not you use EJBs to implement your Web services, your service implementations must interact with SOAP.

The EJB 2.1 specification introduces a standard mechanism for exposing a stateless session bean as a Web service. EJBs written to an earlier specification can take advantage of JAX-RPC and JAXM to interact as a Web service. Note that plain-old-Java-objects (POJOs) can be exposed as Web services using JAX-RPC and JAXM, as well.

Further information pertaining to exposing EJBs as Web services can be found at:

Dig Deeper on Topics Archive

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.