Q

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:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/NewEJB3.html#wp80672
This was first published in July 2003

Dig deeper on Java Web Services

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide

SearchWinDevelopment

Close