Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change 
notification.

The following page has been changed by CyrilleLeClerc:
http://wiki.apache.org/ws/FrontPage/Axis/SessionSupport

The comment on the change is:
update multi session client : one serviceLocator can NOT be shared

------------------------------------------------------------------------------
  
  Sample :
  {{{
- HelloWorldServiceLocator helloWorldServiceLocator = new 
HelloWorldServiceLocator();
+ HelloWorldServiceLocator helloWorldServiceLocatorForJohnDoe = new 
HelloWorldServiceLocator();
- HelloWorldBindingStub bindingStubForJohnDoe = (HelloWorldBindingStub) 
helloWorldServiceLocator
+ HelloWorldBindingStub bindingStubForJohnDoe = (HelloWorldBindingStub) 
-       .gethelloWorldBinding();
+       helloWorldServiceLocator.gethelloWorldBinding();
  
  bindingStubForJohnDoe.setMaintainSession(true);
  
@@ -64, +64 @@

  
   That is to say not only the JSESSIONID cookie is propagated but also any 
other cookie (e.g. : created by an SSO layer, ...)
  
- (!) The internal behavior of client side session support is to store the 
cookies as an instance variable of the {{{Stub}}}
+ (!) The internal behavior of client side session support is to store the 
cookies as an instance variable of the {{{ServiceLocator}}} (via the 
{{{AxisEngine}}})
  
  '''Sample of multi client side sessions'''
  
- A SOAP client may have to open several sessions at the same time. To do this, 
you have to instantiate one {{{Stub}}} per session. 
+ A SOAP client may have to open several sessions at the same time. To do this, 
you have to instantiate one {{{ServiceLocator}}}/{{{Stub}}} per session. 
  
- Axis supports multi client side sessions with no restriction : sessions are 
not associated with threads but only with the {{{Stub}}} instance.
+ Axis supports multi client side sessions with an important restriction : 
'''you must instantiate one Service``Locator per session (ie per Stub)'''.
  
  Sample of mixed invocations :
  {{{
- HelloWorldServiceLocator helloWorldServiceLocator = new 
HelloWorldServiceLocator();
+ HelloWorldServiceLocator helloWorldServiceLocatorForJohnDoe = new 
HelloWorldServiceLocator();
- HelloWorldBindingStub bindingStubForJohnDoe = (HelloWorldBindingStub) 
helloWorldServiceLocator
+ HelloWorldBindingStub bindingStubForJohnDoe = (HelloWorldBindingStub) 
+       helloWorldServiceLocatorForJohnDoe.gethelloWorldBinding();
+ bindingStubForJohnDoe.setMaintainSession(true);
-       .gethelloWorldBinding();
- HelloWorldBindingStub bindingStubForJohnSmith = (HelloWorldBindingStub) 
helloWorldServiceLocator
-       .gethelloWorldBinding();
  
- bindingStubForJohnDoe.setMaintainSession(true);
+ HelloWorldServiceLocator helloWorldServiceLocatorForJohnSmith = new 
HelloWorldServiceLocator();
+ HelloWorldBindingStub bindingStubForJohnSmith = (HelloWorldBindingStub) 
+       helloWorldServiceLocatorJohnSmith.gethelloWorldBinding();
  bindingStubForJohnSmith.setMaintainSession(true);
- 
  
  // Open the JohnDoe session
  String helloJohnDoe = bindingStubForJohnDoe.sayHello("JohnDoe");
@@ -102, +102 @@

  System.out.println("goodByeJohnSmith : " + goodByeJohnSmith);
  }}}
  
- /!\ you should use the same {{{ServiceLocator}}} to instantiate the different 
stubs. The {{{ServiceLocator}}} is a heavyweight object that holds the 
HTTPSender, single instantiation it is particularly important if you use 
CommonsHTTPSender (otherwise, each Stub would use a diferent 
{{{MultiThreadedHttpConnectionManager}}}).
+ /!\ The {{{ServiceLocator}}} is a heavyweight object that holds the 
HTTPSender. However, as the {{{ServiceLocator}}} holds the session data (the 
cookie), it can not be shared by several Stubs.
  
  '''Q: Is it possible to maintain a session for a long duration with Axis 
Client ?'''
  
@@ -116, +116 @@

   Attachments are automatically removed calling {{{Stub.getAttachments()}}} 
and thus should never live for a long duration on the Stub
   * It does not hold critical resources (socket, ...). It is the 
{{{ServiceLocator}}} and not the {{{Stub}}} that may hold opened http 
connections (see Self:FrontPage/Axis/AxisCommonsHTTP )
  
- /!\ It is possible to keep references on an important number of stubs 
instances (for a short or for a long duration) as long as '''all the stubs are 
instanciated by the same {{{ServiceLocator}}}'''. Keep in mind that the 
{{{ServiceLocator}}} is a heavyweight object.
+ /!\ Note that maintaining multi client sessions for a long duration is more 
complex because Service``Locator can not be reused. You must instantiate one 
Service``Locator per session (ie per Stub). Due to this, the memory footprint 
will be much more important. In suc a case, using the {{{CommonsHTTPSender}}} 
instead of the {{{HTTPSender}}} will add a big overweight.
  

Reply via email to