You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Zsolt Kúti <ku...@prolan.hu> on 2012/06/20 10:34:26 UTC

How to cookie renewal?

Hello,

In my application I can successfully call a WCF WS. The session start
with a  login[*] where a specific cookie is provided by the server and
this is set as an option in the Axis client for further use.

The problem is that this cookie expires after some time. It needs to be
renewed otherwise the server rejects further requests.

The server signals this renewal request by timely sending a Set-Cookie
tag with a new value and expiry date. My problem is that I couldn't yet
find out how to get this information with Axis. 

These return nulls:

MessageContext inMC =
service._getServiceClient().getLastOperationContext().getMessageContexts().get("In");
String c1 =
(String)inMC.getServiceContext().getProperty(HTTPConstants.HEADER_SET_COOKIE);
String c2 =
(String)inMC.getServiceContext().getProperty(HTTPConstants.HEADER_SET_COOKIE2);


[*]: For the time being the login processing and cookie setting is done
directly via HttpsURLConnection and SOAP.


Can anyone tell me how to do this?

Thank you!

Zsolt

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: How to cookie renewal?

Posted by Zsolt Kúti <ku...@prolan.hu>.
Thu, 21 Jun 2012 15:23:36 +0200 -n
Stadelmann Josef <jo...@axa-winterthur.ch> írta:

> Hi Zsolt,
> 
> 1. I don't have the solution to your problem, but maybe a meager hint.
> 
> The problem is that this cookie expires after some time.
> 
> The simplest solution would be to renew the cookie at a frequency
...

Hello Josef,

Thank you for your answer! It is definitely some food for thinking :-)
My use case finally proved to be a bit simpler, though.
After some debugging, source scrutiny and further API reading it
revealed that the headears can be gotten by:
CommonsTransportHeaders ho = (CommonsTransportHeaders)
ctx.getProperty(MessageContext.TRANSPORT_HEADERS);

The catch is that CTH is a bit buggy (or the idea of handling header
fields this way is broken). In the constructor a Header[] is passed that
can contain multiple "Set-Cookie" elements. CTH, however uses a map
internally (with names as keys) thereby loosing all but the last of
them. Fortunately the original array is still conatined in CTH, so I
could get the one I needed by reflection. Ugly, I know. If someone
knows a better way it would be welcome!

Bye!

Zsolt

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


AW: How to cookie renewal?

Posted by Stadelmann Josef <jo...@axa-winterthur.ch>.
Hi Zsolt,

1. I don't have the solution to your problem, but maybe a meager hint.

The problem is that this cookie expires after some time.

The simplest solution would be to renew the cookie at a frequency higher than the cookie timeout period.
You can achieve this by running in a separate client thread a timer which does nothing else but renews the cookie when it triggers.

BUT - OK - the cookie times out at the server not at the client.
In which case the server likes to warn the client at any arbitrary point in time. 
So the occurrence of the servers warning is true asynchrony from a clients view.

Who then at the client listens all-time for this server side originating warning event?

2. How do real asynchronous communication on the wire work?
a) You have to configure the client with the all-time-running-listener and
b) you have to tell the server by using ws-addressing at which address and port 
   the client side running-listener is listening for the servers asynchronous cookie time-out-event 
c) and you have to establish the client in way that up on receiving the asynchronous event from the 
   server at the listener, the listener then knows how to call the supportive call-back-routine. 

3. Up on receiving the servers time-out-warning at this client side callback routine 
   then client has to invoke the server with what is required to re-new the cookie.

I think - what you should do is - going into the samples and study the non-blocking but true on the wire 
asynchronous client server communication examples of axis2. Also reading all about asynchronous client 
server communication but also about asynchronous transports may help you to find your solution.

Of big help is a TCPMONITOR or any other network tool like Wireshark etc.

Also http://axis.apache.org/axis2/java/core/docs/jaxws-guide.html#HTTPSession
may help, after reading the things said for asynchrony.

Maybe fiddling with the scope="    " in the service.xml may help to setup cl/sv communication with a different pattern.

Josef


-----Ursprüngliche Nachricht-----
Von: Zsolt Kúti [mailto:kuti.zsolt@prolan.hu] 
Gesendet: Donnerstag, 21. Juni 2012 09:26
An: java-user@axis.apache.org
Betreff: Re: How to cookie renewal?

Has anybody seen this problem?

I've been trying to find the way in the API to getting the http
response header with no success yet.

Any help appreciated!

Zsolt

Wed, 20 Jun 2012 10:34:26 +0200 -n
Zsolt Kúti <ku...@prolan.hu> írta:

> Hello,
> 
> In my application I can successfully call a WCF WS. The session start
> with a  login[*] where a specific cookie is provided by the server and
> this is set as an option in the Axis client for further use.
> 
> The problem is that this cookie expires after some time. It needs to
> be renewed otherwise the server rejects further requests.
> 
> The server signals this renewal request by timely sending a Set-Cookie
> tag with a new value and expiry date. My problem is that I couldn't
> yet find out how to get this information with Axis. 
> 
> These return nulls:
> 
> MessageContext inMC =
> service._getServiceClient().getLastOperationContext().getMessageContexts().get("In");
> String c1 =
> (String)inMC.getServiceContext().getProperty(HTTPConstants.HEADER_SET_COOKIE);
> String c2 =
> (String)inMC.getServiceContext().getProperty(HTTPConstants.HEADER_SET_COOKIE2);
> 
> 
> [*]: For the time being the login processing and cookie setting is
> done directly via HttpsURLConnection and SOAP.
> 
> 
> Can anyone tell me how to do this?
> 
> Thank you!



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: How to cookie renewal?

Posted by Zsolt Kúti <ku...@prolan.hu>.
Has anybody seen this problem?

I've been trying to find the way in the API to getting the http
response header with no success yet.

Any help appreciated!

Zsolt

Wed, 20 Jun 2012 10:34:26 +0200 -n
Zsolt Kúti <ku...@prolan.hu> írta:

> Hello,
> 
> In my application I can successfully call a WCF WS. The session start
> with a  login[*] where a specific cookie is provided by the server and
> this is set as an option in the Axis client for further use.
> 
> The problem is that this cookie expires after some time. It needs to
> be renewed otherwise the server rejects further requests.
> 
> The server signals this renewal request by timely sending a Set-Cookie
> tag with a new value and expiry date. My problem is that I couldn't
> yet find out how to get this information with Axis. 
> 
> These return nulls:
> 
> MessageContext inMC =
> service._getServiceClient().getLastOperationContext().getMessageContexts().get("In");
> String c1 =
> (String)inMC.getServiceContext().getProperty(HTTPConstants.HEADER_SET_COOKIE);
> String c2 =
> (String)inMC.getServiceContext().getProperty(HTTPConstants.HEADER_SET_COOKIE2);
> 
> 
> [*]: For the time being the login processing and cookie setting is
> done directly via HttpsURLConnection and SOAP.
> 
> 
> Can anyone tell me how to do this?
> 
> Thank you!



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org