HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
httpRequestFactory.setConnectionRequestTimeout(10*1000);
httpRequestFactory.setConnectTimeout(10*1000);
httpRequestFactory.setReadTimeout(10*1000);
httpRequestFactory.setBufferRequestBody(false);
RestTemplate template = new RestTemplate(httpRequestFactory);
ClientHttpRequestFactory clientFactory = new HttpComponentsClientHttpRequestFactory();
template.setRequestFactory(clientFactory);
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
@SuppressWarnings({ "rawtypes", "unchecked" })
HttpEntity<String> requestEntity = new HttpEntity("", requestHeaders);
ResponseEntity<QueryResult<String>> responseEntity = template.exchange(uri, HttpMethod.POST, requestEntity,
new ParameterizedTypeReference<QueryResult<String>>() {
});