[jboss-user] [JBoss Seam] - Is there a JBossWS client example for invoking a Seam ws?

lowecg2004 do-not-reply at jboss.com
Mon Jul 30 06:06:00 EDT 2007


I've successfully setup a Seam web service, generated the proxies using wsconsume and installed the Seam conversation SOAP handler.

I'm having real difficulty finding out how to add/read the conversationId SOAP header.  Without it I just get this exception:

Caused by: java.lang.NullPointerException
  | 	at org.jboss.seam.webservice.SOAPRequestHandler.extractConversationId(SOAPRequestHandler.java:137)
  | 	at org.jboss.seam.webservice.SOAPRequestHandler.handleInbound(SOAPRequestHandler.java:75)
  | 	at org.jboss.seam.webservice.SOAPRequestHandler.handleMessage(SOAPRequestHandler.java:56)
  | 	at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:295)
  | 	at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:140)
  | 	... 27 more

Could anyone point me to the right documentation/example/anything that might help?

Shouldn't the lack of conversationId header just be ignored since that implies all my Seam web services must be conversational?  I may wish to have a mix of web services where some may be stateless or just work at the session context?

I tried implementing a web service without the SOAP handler (because of the aforementioned NPE) using a similar example to a simple stateful web service example suggested by Rama Pulavarthi:

http://weblogs.java.net/blog/ramapulavarthi/archive/2006/06/maintaining_ses.html

The web service is invoked just fine, however anything I save to HttpSession using setAttribute() does not survive beyond the request.  So, on a subsequent request to a servlet using the JSESSIONID obtained from the WS call, the corresponding getAttribute call returns null.

I tried to have a go at debugging this and thought that SessionContext.flush() might be a good place to start digging around (my web service also placed some values into SessionContext) but this was never called.  I suppose that makes sense given that I commented out the handler responsible for managing contexts ;) However, could the lack of SOAP handler also cause the values I saved to a regular HttpSession to not  be saved?

Cheers,

Chris

Here is my WS code:

@Name("developmentService")
  | @Stateless
  | @WebService(name = "DevelopmentService", serviceName = "DevelopmentService" )
  | public class DevelopmentAuthenticator implements DevelopmentServiceRemote
  | {
  |   @Logger Log log;
  |   
  |   @Resource
  |   private WebServiceContext wsContext;
  |   
  |   @WebMethod
  |   public boolean login(final String username,
  |                        final String password) {
  |     
  |     final MessageContext mc = wsContext.getMessageContext();
  |     
  |     // This would be called during an AppletViewer session before any server calls. Therefore,
  |     // create a HttpSession so the HTTP response has a JSESSIONID cookie which can be used
  |     // by all other server requests.
  |     final HttpSession session =
  |       ((HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getSession();
  |     
  |     if (session == null) {
  |         throw new WebServiceException("No session in WebServiceContext");
  |     }
  |     
  |     // do authentication
  |     Identity.instance().setUsername(username);
  |     Identity.instance().setPassword(password);
  |     
  |     Identity.instance().login();
  |     
  |     final boolean isLoggedIn = Identity.instance().isLoggedIn();
  |     
  |     if (isLoggedIn) {
  |       // Authenticator stores the userId on the SessionContext
  |       final Integer userId = (Integer) Contexts.getSessionContext().get("userId");
  | 
  |       // verify that userId is set
  |       if (userId == null) {
  |         log.warn("User ID not set after successful login in web service call.");
  |       }
  |       
  |       // transfer the user id to the HttpSession to allow access from all JEE entities,
  |       // not just Seam components.
  |       session.setAttribute("userId", userId);
  |       
  |       log.info("adding userId: {0} to session {1}", session.getAttribute("userId"), session.getId());
  |     }
  |     
  |     return isLoggedIn;
  |   }  
  | 
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068650#4068650

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068650



More information about the jboss-user mailing list