You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Nicola D'Elia <ni...@sinapsi.com> on 2009/08/27 17:42:39 UTC

Concurrent Test for Stateful WS

Hi
i would like to do a concurrent test of a stateful web service that uses the
jax-ws session support.

Basically this means that every jax-ws client must use a different
JSESSIONID.

I did the following to enable the session support on the client side:

        BindingProvider client = (BindingProvider) ws;
        client.getRequestContext().put(SESSION_MAINTAIN_PROPERTY, true);

But every thread that uses the same ws client definition share the same
JSESSIONID.

I think i have to resort to having several different jax-ws client:

  <jaxws:client id="wsClient"
serviceClass="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"
address="http://localhost:${ws.port}/${ws.path}/polimi" >
    <jaxws:dataBinding>
      <ref bean="aegis" />
    </jaxws:dataBinding>
  </jaxws:client>

  <jaxws:client id="wsClient2"
serviceClass="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"
address="http://localhost:${ws.port}/${ws.path}/polimi" >
    <jaxws:dataBinding>
      <ref bean="aegis" />
    </jaxws:dataBinding>
  </jaxws:client>

....

Is there another way to cope with that ?

Isn't there a prototype scope for jax-ws client ?



Thanks


Nicola

Re: Concurrent Test for Stateful WS

Posted by Nicola D'Elia <ni...@sinapsi.com>.
Thanks Daniel, that's exactly what i did.

This ensures that you have a separate http conduit for each thread.


Nicola




On Fri, Aug 28, 2009 at 9:52 PM, Daniel Kulp <dk...@apache.org> wrote:

>
> I think if you make the factory in this case "scope=prototype", it will
> work
> for you.
>
> Dan
>
>
> On Thu August 27 2009 12:29:40 pm Nicola D'Elia wrote:
> > actually i have found the configuration to instanciate different ws
> client,
> > by thefining a factory:
> >
> >   <bean id="wsClientFactory"
> > class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
> >     <property name="serviceClass"
> > value="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"/>
> >     <property name="address" value="http://localhost:
> > ${ws.port}/${ws.path}/polimi"/>
> >     <property name="dataBinding" ref="aegis" />
> >   </bean>
> >
> > I am doing the following concurrent test:
> >
> >     @Test(invocationCount = 4, threadPoolSize = 2)
> >     public void testConcurrentLogin() {
> >         BindingProvider client = (BindingProvider) factory.create();
> >         client.getRequestContext().put(SESSION_MAINTAIN_PROPERTY, true);
> >         System.out.println(client);
> >         PolimiWebService ws = (PolimiWebService) client;
> >
> >         ...
> >
> >         ws.logout();
> >     }
> >
> > The problem is that even though the client instances are different :
> >
> > org.apache.cxf.jaxws.JaxWsClientProxy@19cd5f5
> > org.apache.cxf.jaxws.JaxWsClientProxy@70c38c
> > org.apache.cxf.jaxws.JaxWsClientProxy@195ff24
> > org.apache.cxf.jaxws.JaxWsClientProxy@161509b
> >
> > They all share the same JSESSIONID !
> >
> > Since the call to logout invalidates the session, the test got broken.
> >
> > How is it possible for each client to keep a JSESSIONID instances from
> the
> > others' for its own session ?
> >
> >
> > Nicola
> >
> > On Thu, Aug 27, 2009 at 5:42 PM, Nicola D'Elia
> <ni...@sinapsi.com>wrote:
> > > Hi
> > > i would like to do a concurrent test of a stateful web service that
> uses
> > > the jax-ws session support.
> > >
> > > Basically this means that every jax-ws client must use a different
> > > JSESSIONID.
> > >
> > > I did the following to enable the session support on the client side:
> > >
> > >         BindingProvider client = (BindingProvider) ws;
> > >         client.getRequestContext().put(SESSION_MAINTAIN_PROPERTY,
> true);
> > >
> > > But every thread that uses the same ws client definition share the same
> > > JSESSIONID.
> > >
> > > I think i have to resort to having several different jax-ws client:
> > >
> > >   <jaxws:client id="wsClient"
> > > serviceClass="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"
> > > address="http://localhost:${ws.port}/${ws.path}/polimi" >
> > >     <jaxws:dataBinding>
> > >       <ref bean="aegis" />
> > >     </jaxws:dataBinding>
> > >   </jaxws:client>
> > >
> > >   <jaxws:client id="wsClient2"
> > > serviceClass="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"
> > > address="http://localhost:${ws.port}/${ws.path}/polimi" >
> > >     <jaxws:dataBinding>
> > >       <ref bean="aegis" />
> > >     </jaxws:dataBinding>
> > >   </jaxws:client>
> > >
> > > ....
> > >
> > > Is there another way to cope with that ?
> > >
> > > Isn't there a prototype scope for jax-ws client ?
> > >
> > >
> > >
> > > Thanks
> > >
> > >
> > > Nicola
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: Concurrent Test for Stateful WS

Posted by Daniel Kulp <dk...@apache.org>.
I think if you make the factory in this case "scope=prototype", it will work 
for you.

Dan


On Thu August 27 2009 12:29:40 pm Nicola D'Elia wrote:
> actually i have found the configuration to instanciate different ws client,
> by thefining a factory:
>
>   <bean id="wsClientFactory"
> class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
>     <property name="serviceClass"
> value="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"/>
>     <property name="address" value="http://localhost:
> ${ws.port}/${ws.path}/polimi"/>
>     <property name="dataBinding" ref="aegis" />
>   </bean>
>
> I am doing the following concurrent test:
>
>     @Test(invocationCount = 4, threadPoolSize = 2)
>     public void testConcurrentLogin() {
>         BindingProvider client = (BindingProvider) factory.create();
>         client.getRequestContext().put(SESSION_MAINTAIN_PROPERTY, true);
>         System.out.println(client);
>         PolimiWebService ws = (PolimiWebService) client;
>
>         ...
>
>         ws.logout();
>     }
>
> The problem is that even though the client instances are different :
>
> org.apache.cxf.jaxws.JaxWsClientProxy@19cd5f5
> org.apache.cxf.jaxws.JaxWsClientProxy@70c38c
> org.apache.cxf.jaxws.JaxWsClientProxy@195ff24
> org.apache.cxf.jaxws.JaxWsClientProxy@161509b
>
> They all share the same JSESSIONID !
>
> Since the call to logout invalidates the session, the test got broken.
>
> How is it possible for each client to keep a JSESSIONID instances from the
> others' for its own session ?
>
>
> Nicola
>
> On Thu, Aug 27, 2009 at 5:42 PM, Nicola D'Elia 
<ni...@sinapsi.com>wrote:
> > Hi
> > i would like to do a concurrent test of a stateful web service that uses
> > the jax-ws session support.
> >
> > Basically this means that every jax-ws client must use a different
> > JSESSIONID.
> >
> > I did the following to enable the session support on the client side:
> >
> >         BindingProvider client = (BindingProvider) ws;
> >         client.getRequestContext().put(SESSION_MAINTAIN_PROPERTY, true);
> >
> > But every thread that uses the same ws client definition share the same
> > JSESSIONID.
> >
> > I think i have to resort to having several different jax-ws client:
> >
> >   <jaxws:client id="wsClient"
> > serviceClass="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"
> > address="http://localhost:${ws.port}/${ws.path}/polimi" >
> >     <jaxws:dataBinding>
> >       <ref bean="aegis" />
> >     </jaxws:dataBinding>
> >   </jaxws:client>
> >
> >   <jaxws:client id="wsClient2"
> > serviceClass="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"
> > address="http://localhost:${ws.port}/${ws.path}/polimi" >
> >     <jaxws:dataBinding>
> >       <ref bean="aegis" />
> >     </jaxws:dataBinding>
> >   </jaxws:client>
> >
> > ....
> >
> > Is there another way to cope with that ?
> >
> > Isn't there a prototype scope for jax-ws client ?
> >
> >
> >
> > Thanks
> >
> >
> > Nicola

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Concurrent Test for Stateful WS

Posted by Nicola D'Elia <ni...@sinapsi.com>.
actually i have found the configuration to instanciate different ws client,
by thefining a factory:

  <bean id="wsClientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
    <property name="serviceClass"
value="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"/>
    <property name="address" value="http://localhost:
${ws.port}/${ws.path}/polimi"/>
    <property name="dataBinding" ref="aegis" />
  </bean>

I am doing the following concurrent test:

    @Test(invocationCount = 4, threadPoolSize = 2)
    public void testConcurrentLogin() {
        BindingProvider client = (BindingProvider) factory.create();
        client.getRequestContext().put(SESSION_MAINTAIN_PROPERTY, true);
        System.out.println(client);
        PolimiWebService ws = (PolimiWebService) client;

        ...

        ws.logout();
    }

The problem is that even though the client instances are different :

org.apache.cxf.jaxws.JaxWsClientProxy@19cd5f5
org.apache.cxf.jaxws.JaxWsClientProxy@70c38c
org.apache.cxf.jaxws.JaxWsClientProxy@195ff24
org.apache.cxf.jaxws.JaxWsClientProxy@161509b

They all share the same JSESSIONID !

Since the call to logout invalidates the session, the test got broken.

How is it possible for each client to keep a JSESSIONID instances from the
others' for its own session ?


Nicola




On Thu, Aug 27, 2009 at 5:42 PM, Nicola D'Elia <ni...@sinapsi.com>wrote:

> Hi
> i would like to do a concurrent test of a stateful web service that uses
> the jax-ws session support.
>
> Basically this means that every jax-ws client must use a different
> JSESSIONID.
>
> I did the following to enable the session support on the client side:
>
>         BindingProvider client = (BindingProvider) ws;
>         client.getRequestContext().put(SESSION_MAINTAIN_PROPERTY, true);
>
> But every thread that uses the same ws client definition share the same
> JSESSIONID.
>
> I think i have to resort to having several different jax-ws client:
>
>   <jaxws:client id="wsClient"
> serviceClass="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"
> address="http://localhost:${ws.port}/${ws.path}/polimi" >
>     <jaxws:dataBinding>
>       <ref bean="aegis" />
>     </jaxws:dataBinding>
>   </jaxws:client>
>
>   <jaxws:client id="wsClient2"
> serviceClass="com.sinapsi.ws.ext.polimi.interfaces.PolimiWebService"
> address="http://localhost:${ws.port}/${ws.path}/polimi" >
>     <jaxws:dataBinding>
>       <ref bean="aegis" />
>     </jaxws:dataBinding>
>   </jaxws:client>
>
> ....
>
> Is there another way to cope with that ?
>
> Isn't there a prototype scope for jax-ws client ?
>
>
>
> Thanks
>
>
> Nicola
>
>