I am trying to learn about J2EE and web services (in GlassFish 3.1). This question is a bit of a follow up to this.
I have figured out how to use Stateless Session Beans and the Web Service. I am really only using the Web Service (@WebService
) out of convenience since I would rather not parse messages by hand. Although I would prefer something lighter than SOAP if possible. I have however run into a problem when I want to maintain a state of some sort (such as through Stateful Session Beans). I have searched this site and several others recommending me to avoid this because it can lead to difficult to find bugs and limits scalability.
Suppose I have a user who has just executed the "userLogin" method and it has succeeded. How do I then know on the server that the user has already logged in. For example, after logging in the user might call "getProfile()" through SOAP (without any arguments), and I would return the correct information for that user. I know this isn't possible by appending @WebService
to my Stateful Session Bean since that's only valid with @Stateless
.
I know how to store the state if I use an HttpSession (with an HttpServlet) along with Stateless Session Beans, but then I cannot use the nicely generated SOAP messages.
So my question is: how would I solve this problem of maintaining user state, or adapt the problem so that I do not require state?