Seam 2.2.1 and stateless web service
rmemoria Nov 1, 2012 2:37 PMHi all,
I have a web app in SEAM 2.2.1 using JBOSS 4.2.3 in a WAR file.
I've tried SEAM documentation that doens't cover much about that.
I'm trying to implement web services in this app. I notice that when I call the authenticator bean (using the same authenticator I use in web login page), the web service creates a session context and keeps it after the execution of the web service.
This is the authenticator I call
@WebService(name="authenticatorService", serviceName="authenticatorService") @SOAPBinding(style=Style.RPC) public class AuthenticatorService { @WebMethod public String login(String username, String password) { try { Identity.instance().setUsername(username); Identity.instance().setPassword(password); Identity.instance().login(); // testing the caller HttpServletRequest req = (HttpServletRequest)ServletContexts.instance().getRequest(); System.out.println(req.getRemoteAddr()); System.out.println(req.getHeader("User-Agent")); if (Identity.instance().isLoggedIn()) { Identity.instance().logout(); // useless Session.instance().invalidate(); // useless AuthenticatorBean authenticator = (AuthenticatorBean)Component.getInstance("authenticator"); return authenticator.getMySessionId(); } else return "fail"; } catch (Exception e) { return e.getMessage(); } }
As you may see, I'm trying to finish the session immediatelly after the execution of my Web Service, but the session remains.
I see it keeps the session active because I have a
@Observer("org.jboss.seam.preDestroyContext.SESSION")
That is just called after the session timeout (45 minutes).
Does anyone know how to implement pure stateless web services using SEAM?
or maybe, How to terminate the session after execution of the web service?
Thanks,
Ricardo