Aliyon
Aliyon

Reputation: 149

Spring restTemplate

I'm trying to use spring rest template to do a post request to login in.

RestTemplate restTemplate = new RestTemplate();

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

LinkedMultiValueMap<String, Object> mvm = new LinkedMultiValueMap<String, Object>();
mvm.add("LoginForm_Login", "login");
mvm.add("LoginForm_Password", "password");

ResponseEntity<String> result = restTemplate.exchange(uriDWLogin, HttpMethod.POST, requestEntity, String.class);

all goes well, but when I try to send a second request, It generates an error saying :

Business Manager closes your session after 15 minutes

And i need to know can i use the resttemplate to manage sessions.

Upvotes: 0

Views: 1071

Answers (1)

chetank
chetank

Reputation: 402

RestTemplate never manages session, nor do any of the service because all of them are stateless. If you want to manage the state, what you can do is get the token first time and then pass that token each time to the next service call.

Upvotes: 2

Related Questions