开发者

JaxWSProxyFactoryBean sharing HTTP session

We are working on one project where in we are using JaxWSProxyFactoryBean provided by开发者_如何转开发 CXF framework to invoke webservices. I am using SPRING configuration to create clients rather than using API directly in code. I am also setting maintain_session property to make sure session is maintained by WS clients.

<jaxws:client id="userAuthenticationServiceClient1" address="${application.deployment.url}/UserAuthentication" serviceClass="com.authentication.webservice.IUserAuthenticationService" abstract="true" > <jaxws:properties > <entry key="javax.xml.ws.session.maintain"> <value type="java.lang.Boolean">true</value> </entry> </jaxws:properties> </jaxws:client>

But I found that the session is not maintained across various webservices instances. To make it more clear If there are proxy clients like wc1, wc2, wc3. All the operations invoked on wc1 will have its session, while wc2 will create new session. Can someone let me know what settings I need to do so that all the ws clients will share session?


There really isn't an "automatic" way to do it. Each service proxy is designed to be completely separate from the others. However, you can "manually" copy the session cookies from one proxy to the other via:

HTTPConduit conduit1 = (HTTPConduit)ClientProxy.getClient(p1).getConduit(); HTTPConduit conduit2 = (HTTPConduit)ClientProxy.getClient(p2).getConduit(); conduit2.getCookies().putAll(conduit1.getCookies());

That should copy all the cookies from one to the other.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜