Skip to main content

.NET client consuming web service in JAX-WS on tomcat

4 replies [Last post]
tsmojver
Offline
Joined: 2008-07-17

Hello,
I am consuming a web service written in JAX-WS with a .NET client. My client proxy class iwas generated using the wsdl.exe tool. In order to maintain a session on the server, my client needs to set this value. At least, thats what the java client does.

Here is the java code sample. Does anyone know if:
1 - JAX-WS is interoperable between platforms
2 - Does using BindingProvider.SESSION_MAINTAIN_PROPERTY make this a java
specific implementation?
3 - What is the .NET equivalent of this?
4 - What does the put method actually do? I assume it inserts the session maintain value in the soap header.

Hello proxy = new HelloService().getHelloPort();
((BindingProvider)proxy).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);

Any help is greatly appreciated!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jitu
Offline
Joined: 2003-06-14

Since you are using .NET client, you don't have to worry about JAX-WS client details. By setting session property, JAX-WS client sends the cookies back to the server.

vmiharia
Offline
Joined: 2008-01-08

I think the question was (and if not, then my question is) how to enable session on .net client to use stateful web service.

I have a stateful webservice written using HTTPSession described in Rama's blog at http://weblogs.java.net/blog/ramapulavarthi/archive/2006/06/maintaining_... . But I have a .net client. Rama has demonstrated how to enable session on Java client.

((BindingProvider)proxy).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);

My question is how to do it in .Net client. Is it equivalent to enabling cookie ?

Also, if a client does not want to enable cookie, can HTTPSession use URLrewriting to maintain the session ?

Thanks

unsigned_mind
Offline
Joined: 2008-04-22

In order to maintain session when using .NET client, you have to enable Cookies in .NET client. Actually cookies are by default enabled but there is a problem because CookieContainer is null so you have to instantiate it manually like this:

private System.Net.CookieContainer cookies;

when calling web service :
if(cookies == null) {
cookies = new System.Net.CookieContainer();
}
service.CookieContainer = cookies;
service.callLoginMethod(u,p);

Best Regards,

Niksa Jakovljevic

rajiv_dadhich
Offline
Joined: 2010-02-04

Hi,

Is your resolved?
If yes,
Can you please post me the approach you had used to tackle session maintain using JAX-RS interoperable issue.

Thanks and Waiting for your Reply.