Difference between exchange method and execution method in spring rest pattern?

I have three questions!

At first.

I am using a spring structure to send data through a break protocol.

restTemplate.exchange(requestUrl,HttpMethod.POST, request, listVo.getClass()); org.springframework.web.client.RestTemplate.exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<? extends Object> responseType, Object... uriVariables) throws RestClientException 

I used it without any problems, but I want to know the purpose of the responseType parameter. The client does not use response data, but simply uses the response status code / msg. So, I sent pointless string data instead. But the mistake threw that they accept "zero". So I sent the string "null". not zero. Then the error got rid. But there was another problem. Immediately after the client received data from the server and suspended for a long time. Then the next line of codes is executed. What a problem?

Second

I cannot find links that use the execute spring RestTemplate method.

Third

Like the name, What is the difference between the exchange method and the execute method in the spring rest pattern?

Thank you for your time and effort. Greetings.

+5
source share
2 answers

Returns the return type ResponseEntity<T> , and execute T

+3
source

Adapted from the Spring Certified Web Application Developer Exam

Execution and sharing methods can be used for any type of REST call.

The execute method can also be provided by the RequestCallback implementation as a parameter that tells RestTemplate what to do with the request before sending it to the server.

0
source

Source: https://habr.com/ru/post/1208656/


All Articles