[Russell, please review and add to FAQ?]

Q: How does Axis create my backend service objects?  Can I control
   this?

A: Axis supports a "scope" parameter on services, which can be set
   to "request" (make a new object to service each request - this
   is the default), "session" (associate a new object with each
   session), and "application" (all users share a singleton
   object).  WARNING: If you set the scope to "session" or
   "application", it is possible that multiple threads of control
   may attempt to access your object's methods at the same time.
   It is your responsibility to ensure that your objects are
   thread-safe in these cases.

Q: So does Axis support sessions?

A: Yes.  We have a session abstraction which allows an extensible
   set of underlying implementations - take a look at the class
   org.apache.axis.session.Session for details.  In particular, we
   currently support sessions based on HTTP cookies and also
   transport-independent sessions based on SOAP headers.  It is up
   to some handler on the request chain to set up an appropriate
   Session implementation and attach it to the MessageContext with
   MessageContext.setSession() so that anyone who wants to use
   session semantics can get at it.

Q: Cool, SOAP header-based sessions?  How do I make that work?

A: There is a Handler class called "org.apache.axis.handlers.
   SimpleSessionHandler" which implements this functionality.
   You need to include this handler in the request and response
   flows of both your client and your server.  Take a look at
   our session test (test.session.TestSimpleSession) for an
   example.

Q: What else can I do with sessions?

A: Any time after the session context has been established,
   calling getSession() on the current MessageContext will obtain
   you a reference to a Session object.  You may use this object
   like a Hashtable to store arbitrary data associated with this
   Session.  For instance, on one request you might extract the
   caller's name and address from a database (an expensive
   operation), and then cache them in the Session object for fast
   access on subsequent invocations from the same caller.  This
   functionality can be used either by custom Handlers or by
   your backend service object itself.

--Glen

Reply via email to