3 Replies Latest reply on Oct 20, 2010 2:34 PM by ndipiazza

    Seam Conversation thru Web Service

    rcridlig

      Hi,


      My Server application is a web service's one, with use of conversation components. The client is another application (non-web). My problem is that the conversation scope is not maintained across more than one request from client.


      Here are the 2 process I used for conversation propagating:
      - the client send back the conversationId in http header as in the reference documentation.
      - my conversation component use annotations : @Begin , etc...
      - My stateless Webservice delegates conversationnal process to a stateful -scope:CONVERSATION- component



      Is this kind of process should work with seam ?
      Or, is it only working for web client (like browsers) ?


      what I'm using:
      Seam 2.0.0GA
      jboss 4.2.2GA
      jax-ws 2.1


      Thx,
      Raoul

        • 1. Re: Seam Conversation thru Web Service
          tom_goring

          Hi,


          I think you need to do both.


          I.e. make sure your ws client always propagates the conversationId AND make sure you have actually started a long running conversation in your seam back end.

          • 2. Re: Seam Conversation thru Web Service
            bgroeneveld

            We appear to be running into the same issue.  We have defined a RESTEasy service which works nicely, stateless, and we can get it to read / write to our db.  Now we would like to take advantage of Seam's extended persistence context by having the stateless service interact with conversationally scoped Seam components.  To test this we setup a seam app defaulting on startup to MANUAL flush mode


            <core:manager default-flush-mode="MANUAL"


            so we can demonstrate flushing to the db after a second HTTP request to the service while it interacts with conversationally scoped Seam components - but no luck so far.  We have even added this to our config, according to the manual:


            <resteasy:application destroy-session-after-request="false"/>


            Recommendations?

            • 3. Re: Seam Conversation thru Web Service
              ndipiazza
              I think I am having the same problems. I am developing with jboss seam 4.2.3 and making a very very simple REST web service.

              I just login with one REST method doLoginRest, and then secondly i check to see if the login is valid with the REST method testLogin.

              I login, then i call the testLogin method and clearly the login did not stick between method invocations.

              I have <resteasy:application destroy-session-after-request="false"/> set in my components.xml file.

              Any ideas?

              My code is below.


              @Scope(ScopeType.SESSION)
              @Transactional
              public class MyClass {
              @In(required=false) private User currentUser; // don't have to be logged in to use this class
                  /**
                   * Do the login as a REST service.
                   */
                  @GET
                  @Path("/doLogin")
                  public String doLoginRest(@QueryParam("userId") String userId, @QueryParam("password") String password) throws IOException {     
                      Credentials creds = identity.getCredentials();
                      creds.setUsername(userId);
                      creds.setPassword(password);
                      identity.setRememberMe(true);
                      Context session = Contexts.getSessionContext();
                      currentUser = (User) session.get("currentUser"); // This at this point is NOT null, login worked!!!
                      return identity.login();
                  }
                  /**
                   * Test if the login worked
                   */
                  @GET
                  @Path("/testLogin")
                  public String doTestLogin() {     
                      Context session = Contexts.getSessionContext();
                      currentUser = (User) session.get("currentUser");
                      return ""+(currentUser != null); // This is false everytime
                  }
              }