You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jan Kriesten <ja...@renitence.de> on 2007/06/28 10:12:38 UTC

Re: session management / serialization

Hi Dan,

> JaxWsProxyFactoryBean proxyBean = new JaxWsProxyFactoryBean();
> ....
> MyClient client = (MyClient) proxyBean.create();
> BindingProvider bp = (BindingProvider) myclient;


thanks, that should do the trick. :-)

To enable a webapplication using one session per user, one has to create a proxy
for each user-session. This would mean, I'd have to maintain the
JaxWsProxyFactoryBean in the user-session, which fails:

[09:33:06.551] java.io.NotSerializableException:
org.apache.cxf.jaxws.JaxWsClientProxy

Any more ideas on this?

ATM I changed the Service to get the session-id transmitted with every request,
but this way i have to implement my own session-management on the service-side.

Best Regards, --- Jan.


Re: session management / serialization

Posted by Dan Diephouse <da...@envoisolutions.com>.
Objects which are stored in sessions need to be serializable so they can be
replicated across machines or stored in a db/filesystem for a while.

Given your diagram:

SoapServer <--(session A)--> SoapClient/WebServer <--(session B)--> User

Hopefully I understand this correctly - I think what you need to do is have
sort of session/client identifier stored in (session B) which you can use to
retrieve the correct session for our client (session A). It probably depends
on how you want to handle session timeouts, replication, storage, etc, but
you could do something like this:

String id = sessionB.get("sessionId")
MyClient client = clients.get(id);
if (client == null) createNewClient();

client.foo();

I will say that JaxWsClientProxy probably isn't going to be the type of
thing that we're going to make serializable I don't think.

Hope that helps,
- Dan
-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Re: session management / serialization

Posted by Willem Jiang <ni...@iona.com>.
Hi Jan,

I think you have to implement the session manager yourself to manager 
the client proxy :(.

Willem.

Jan Kriesten wrote:
> Hi Jervis,
>
>   
>> Can I ask why you want to put handlerTest object into session? Session object is used on the server side, while Client proxy is used on the client side, not sure how come they are mixed together. Quoted from your previous email: 
>>     
>
> hehe, i guess you don't get the scenario. ;-)
>
> SoapServer <----> SoapClient/WebServer <----> User
>
> So, the Webserver wants a SoapClient<->SoapServer-Connection per User-session,
> so the handlerTest gets on the WebServer in the session.
>
> Best regards, --- Jan.
>
>
>   


Re: session management / serialization

Posted by Jan Kriesten <ja...@renitence.de>.
Hi Jervis,

> Can I ask why you want to put handlerTest object into session? Session object is used on the server side, while Client proxy is used on the client side, not sure how come they are mixed together. Quoted from your previous email: 

hehe, i guess you don't get the scenario. ;-)

SoapServer <----> SoapClient/WebServer <----> User

So, the Webserver wants a SoapClient<->SoapServer-Connection per User-session,
so the handlerTest gets on the WebServer in the session.

Best regards, --- Jan.


RE: session management / serialization

Posted by "Liu, Jervis" <jl...@iona.com>.
Can I ask why you want to put handlerTest object into session? Session object is used on the server side, while Client proxy is used on the client side, not sure how come they are mixed together. Quoted from your previous email: 

"To enable a webapplication using one session per user, one has to create a proxy for each user-session. This would mean, I'd have to maintain the JaxWsProxyFactoryBean in the user-session, which fails:"


Cheers,
Jervis

-----Original Message-----
From: Jan Kriesten [mailto:jan.kriesten@renitence.de]
Sent: 2007?6?28? 17:13
To: cxf-user@incubator.apache.org
Subject: Re: session management / serialization



hi jervis,

>             QName serviceName = new QName("http://apache.org/handler_test", "HandlerTestService");
>             QName portName = new QName("http://apache.org/handler_test", "SoapPort");
>             URL wsdl = HandlerInvocationTest.class.getResource("/wsdl/handler_test.wsdl");
>             HandlerTestService service = new HandlerTestService(wsdl, serviceName);
>             HandlerTest handlerTest = service.getPort(portName, HandlerTest.class);
>             ((BindingProvider)handlerTest).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,  true);

i'm trying to do a

session.put( "service", handlerTest );

within a servlet and session tries to serialize handlerTest, which fails.

regards, --- jan.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: session management / serialization

Posted by Jan Kriesten <ja...@renitence.de>.
hi jervis,

>             QName serviceName = new QName("http://apache.org/handler_test", "HandlerTestService");
>             QName portName = new QName("http://apache.org/handler_test", "SoapPort");
>             URL wsdl = HandlerInvocationTest.class.getResource("/wsdl/handler_test.wsdl");
>             HandlerTestService service = new HandlerTestService(wsdl, serviceName);
>             HandlerTest handlerTest = service.getPort(portName, HandlerTest.class);
>             ((BindingProvider)handlerTest).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,  true);

i'm trying to do a

session.put( "service", handlerTest );

within a servlet and session tries to serialize handlerTest, which fails.

regards, --- jan.



RE: session management / serialization

Posted by "Liu, Jervis" <jl...@iona.com>.
Hi Jan, can you be more specific on what you are trying to do on the client side please? If you are using a JAX-WS client, following code should work:

            QName serviceName = new QName("http://apache.org/handler_test", "HandlerTestService");
            QName portName = new QName("http://apache.org/handler_test", "SoapPort");
            URL wsdl = HandlerInvocationTest.class.getResource("/wsdl/handler_test.wsdl");
            HandlerTestService service = new HandlerTestService(wsdl, serviceName);
            HandlerTest handlerTest = service.getPort(portName, HandlerTest.class);
            ((BindingProvider)handlerTest).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,  true);

            List<String> resp = handlerTest.ping();

Cheers,
Jervis

-----Original Message-----
From: Jan Kriesten [mailto:jan.kriesten@renitence.de]
Sent: 2007?6?28? 16 :52
To: cxf-user@incubator.apache.org
Subject: Re: session management / serialization



Hi Willem,

> Can you tell me if you are trying to call the service which is deploied
> into the web container ?
> And if you can show us you test case to reproduce it , we will solve the
> issue soon.

actually, the problem with the JaxWsProxyFactoryBean not being serializable
happens on the client side, not within the service.

I've deployed the CXFServlet in a web container (resin 3.1.1 - which doesn't yet
support @Resource WebServiceContext, but that's not your problem ;-)).

My problem is, that when I generate a proxy per user-session on the client side,
the proxy doesn't get serialized into the session-space and on getting back to
it, I get a NPE.

It might be really the only fault-tolerant way to submit the session-id with
every request...

Best regards, --- Jan.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: session management / serialization

Posted by Jan Kriesten <ja...@renitence.de>.
Hi Willem,

> Can you tell me if you are trying to call the service which is deploied
> into the web container ?
> And if you can show us you test case to reproduce it , we will solve the
> issue soon.

actually, the problem with the JaxWsProxyFactoryBean not being serializable
happens on the client side, not within the service.

I've deployed the CXFServlet in a web container (resin 3.1.1 - which doesn't yet
support @Resource WebServiceContext, but that's not your problem ;-)).

My problem is, that when I generate a proxy per user-session on the client side,
the proxy doesn't get serialized into the session-space and on getting back to
it, I get a NPE.

It might be really the only fault-tolerant way to submit the session-id with
every request...

Best regards, --- Jan.



Re: session management / serialization

Posted by Willem Jiang <ni...@iona.com>.
Hi Jan,

Can you tell me if you are trying to call the service which is deploied 
into the web container ?
And if you can show us you test case to reproduce it , we will solve the 
issue soon.

I just added the session support in cxf-rt-transport-http-jetty[1] which 
just works for standalone mode.
After I finish the testing work, I will commit the code.
Please monitor the commit letter :).

[1] https://issues.apache.org/jira/browse/CXF-750

Cheers,
Willem.




Jan Kriesten wrote:
> Hi Dan,
>
>   
>> JaxWsProxyFactoryBean proxyBean = new JaxWsProxyFactoryBean();
>> ....
>> MyClient client = (MyClient) proxyBean.create();
>> BindingProvider bp = (BindingProvider) myclient;
>>     
>
>
> thanks, that should do the trick. :-)
>
> To enable a webapplication using one session per user, one has to create a proxy
> for each user-session. This would mean, I'd have to maintain the
> JaxWsProxyFactoryBean in the user-session, which fails:
>
> [09:33:06.551] java.io.NotSerializableException:
> org.apache.cxf.jaxws.JaxWsClientProxy
>
> Any more ideas on this?
>
> ATM I changed the Service to get the session-id transmitted with every request,
> but this way i have to implement my own session-management on the service-side.
>
> Best Regards, --- Jan.
>
>
>