July 2018
Intermediate to advanced
268 pages
7h 36m
English
The retrieve() method is a simple method, using which the response body can be retrieved. If you want to have more control over returned responses, the exchange() method can be used to retrieve the response. We have used both of the methods in our sample application; the code snippets for the two methods in the WebClientTestImpl class are as follows:
@Overridepublic Mono<Movie> getMovieById(Long id) return this.webClient.get().uri("/{id}", id) .retrieve().bodyToMono(Movie.class);}@Overridepublic Mono<Movie> saveMovie(Movie movie) { return webClient.post().uri("/") .body(BodyInserters.fromObject(movie)) .exchange().flatMap( clientResponse -> clientResponse.bodyToMono(Movie.class) );}
In the first ...
Read now
Unlock full access