Hello Neil,

   Axis 1.3 stubs are NOT thread safe. You will face problems if your
calls involve soap headers or attachments for example.

   Note that can can reuse a stub. By the way, reusing a stub is the
pattern to maintain a client side session (you then also have to call
stub.setMaintainSession(true) ).

   If you use stateless soap calls, the simplest pattern is to use :
- a single instance of the serviceLocator (acts as the stub factory)
- to instantiate one new instance of the stub for each call and then
throw this instance away

   If you use stateful soap calls, the simplest pattern is to use :
- a single instance of the serviceLocator (acts as the stub factory)
- to instantiate one new instance of the stub per session, perform the
calls and then throw this instance away


   Note that the cost of instantiating new stubs is small because the
stubs are lightweight objects.
   An optimization to lower this cost could be to :
- reduce the initial size of the vectors variables of
org.apache.axis.client.Stub : "headers" and "attachments"
- change to static the instance variables of the generated stubs
(com.mycompany.MyServiceBindingStub) and initialize them in a static
block : "cachedSerClasses", "cachedSerQNames", "cachedSerFactories",
"cachedDeserFactories"

   Not that is is very important to reuse the same instance of the
serviceLocator to instantiate all the stubs because :
- serviceLocator is a heavyweight object (it holds its own AxisEngine)
- if you use the CommonsHTTPSender, the serviceLocator holds this
Sender (via the AxisEngine) and this CommonsHTTPSender MUST be shared
among Stubs to benefit of the pooled http connections


   I have deduced these points analyzing Axis source code. If somebody
can confirm or contradict ?

   Hope this help,

   Cyrille

--
Cyrille Le Clerc
[EMAIL PROTECTED]
[EMAIL PROTECTED]

On 1/19/06, Ferguson, Neil, VF-NZ <[EMAIL PROTECTED]> wrote:
>
>
> Hi.
>
> I was wondering if anybody could give me a definitive answer on whether the
> stub generated by WSDL2Java (Axis 1.3) is thread-safe (i.e. it can safely be
> used by multiple concurrent threads without external synchronization)?
> Unfortunately "I've tried it and it works" probably won't be enough for me,
> I'll probably need some documentation to back it up.
>
> Also, if it is thread-safe are there any performance implications of
> multiple threads using it (i.e. it does lots of synchronization internally)?
>
> Perhaps I should just pool my stubs to be on the safe side. Any thoughts?
>
> Thanks.
>
> Neil.
>  ________________________________
>
>
> Have you seen our website? .... www.vodafone.co.nz
>
> Manage Your Account, check your Vodafone Mail and send web2TXT online:
> www.vodafone.co.nz/myvodafone
>   ________________________________
>
> CAUTION: This correspondence is confidential and intended for the named
> recipient(s) only.  If you are not the named recipient and receive this
> correspondence in error, you must not copy, distribute or take any action in
> reliance on it and you should delete it from your system and notify the
> sender immediately.  Thank you.
>
> Unless otherwise stated, any views or opinions expressed are solely those of
> the author and do not represent those of Vodafone New Zealand Limited.
>
> 20 Viaduct Harbour Avenue, Private Bag 92161, Auckland 1030
> Telephone + 64 9 355 2000
> Facsimile + 64 9 355 2001
>  ________________________________
>

Reply via email to