Posted: Thu Nov 23, 2017 7:33 am Post subject: Multiple web service request with a single HTTPRequest Node
Newbie
Joined: 23 Nov 2017 Posts: 2
Hi all,
Is there a way to maintain a single session with a HTTPRequest node wherein we can achieve the below scenario :
1) Hit the URL1 with http method as 'GET' which returns a token in response
2) Maintain the same session
3) Hit the URL2 with http method as 'PUT' with a message, passing the token from #1 in the http header.
Where URL1 and URL2 are having the same host and port, the URI changes.
I am seeing that the connection is closed after the response is received for GET and session is closed for #3 which returns a 403 error as the token is not valid for the new session.
Have tried "HTTP.KeepAlive = TRUE" option, but this does not work.
Posted: Mon Nov 27, 2017 10:29 pm Post subject: resolved
Newbie
Joined: 23 Nov 2017 Posts: 2
This is resolved -
Solution
Add the cookie attribute in the request header:
CREATE LASTCHILD OF OutputRoot.HTTPRequestHeader NAME 'Cookie' VALUE InputRoot.HTTPResponseHeader."set-cookie";
where set-cookie would be the cookie value received from the response from the previous request.
Flow:
InputQueue -> 1st Compute node do GET --> 1st HTTP request Node --> 2nd Compute node do PUT --> 2nd HTTP request Node --> Output
requirement is to get a token from GET first and use the token to PUT in the same session.
In Java use CookieManager
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum