ClientResponse's toEntity method converts it to a ResponseEntity<Mono> object. So I came up with the following.

public ResponseEntity<String> doGet2(HttpServletRequest request, URI uri) {
    ClientResponse clientResponse = webClient.get()
            .uri(uri.toASCIIString())
            .headers(headers -> headers.putAll(processRequest(request)))
            .exchange()
            .block();

    return clientResponse.toEntity(String.class).block();
}
Answer from Philip John on Stack Overflow
🌐
Medium
medium.com › @chuchip › using-the-webclient-class-reactive-programming-in-java-c3f2cb2eafb3
Using the webClient class. Reactive programming in Java | by Jesus J. Puente | Medium
August 27, 2019 - Mono<ClientResponse> respuesta1 = webClient.get().uri("?queryParam={name}","SPEED".equals(param)?"SPEED":"STOP").exchange(); Finally, a Mono object is created, which will be the result of the previous two, using the zip function.
🌐
Spring
docs.spring.io › spring-framework › docs › current › javadoc-api › org › springframework › web › reactive › function › client › ClientResponse.html
ClientResponse (Spring Framework 7.0.8 API)
Return a builder to mutate this response, for example to change the status, headers, cookies, and replace or transform the body. ... Release the body of this response. ... Return the request associated with the response. ... Return the HTTP status code as an HttpStatusCode value. ... Return the strategies used to convert the body of this response. ... Return this response as a delayed ResponseEntity containing status and headers, but no body.
🌐
Spring
docs.spring.io › spring-framework › reference › integration › rest-clients.html
REST Clients :: Spring Framework
There are adapter implementations for RestClient, WebClient, and RestTemplate. Occasionally, it may be useful to intercept client invocations through a decorator configurable in the HttpServiceProxyFactory.Builder. For example, you can apply built-in decorators to suppress 404 exceptions and return a ResponseEntity with NOT_FOUND and a null body:
🌐
Reflectoring
reflectoring.io › spring-webclient
Sending HTTP requests with Spring WebClient
May 25, 2021 - ... ResponseEntity<String> response = client.get() // ... .retrieve() .toEntity(String.class) .block(); HttpHeaders responseHeaders = response.getHeaders(); List<String> headerValue = responseHeaders.get("header-name"); In the examples above, ...
🌐
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
🌐
HowToDoInJava
howtodoinjava.com › home › spring webflux › spring boot webclient post example
Spring Boot WebClient POST Example
September 14, 2023 - Employee newEmployee = ...; //Create a new employee object webClient.post() .uri("/employees") .bodyValue(BodyInserters.fromValue(newEmployee)) .retrieve() .toBodilessEntity() .subscribe( responseEntity -> { // Handle success response here ...
Find elsewhere
🌐
Baeldung
baeldung.com › home › spring › spring webflux › spring webclient exchange() vs retrieve()
Spring WebClient exchange() vs retrieve() | Baeldung
May 2, 2024 - Additionally, let’s see an example that makes a GET request to the /users endpoint: @GetMapping("/users") Flux<User> retrieveAllUsers() { return client.get() .retrieve() .bodyToFlux(User.class) .onResumeError(Flux::error); } Here, the method ...
🌐
Baeldung
baeldung.com › home › spring › spring webflux › how to get response body when testing the status code in webflux webclient
How to Get Response Body When Testing the Status Code in WebFlux WebClient | Baeldung
June 25, 2024 - Spring WebFlux client provides many ways to process the responses of our web requests. We look at a few techniques to process the response body, based on status code, using functional programming.
🌐
Techsphere
techsphere.dev › home › http request with spring webclient
Http Request with Spring WebClient - Techsphere
May 24, 2025 - WebClient can be used for making both synchronous or asynchronous HTTP requests · To send an HTTP GET Request we will have to use .get() method, and for HTTP POST request we will have to use .post() method along with .body() to send the request body · Response bodies can be parsed to specific higher-level types by by providing more specific types. Response headers can be extracted from the response by parsing the response to ResponseEntity
🌐
Spring
docs.spring.io › spring-framework › docs › 5.0.0.M5_to_5.0.0.RC1 › Spring Framework 5.0.0.RC1 › org › springframework › web › reactive › function › client › WebClient.ResponseSpec.html
WebClient.ResponseSpec
Extract the body to a Flux. If the response has status code 4xx or 5xx, the Flux will contain a WebClientException. ... Returns the response as a delayed ResponseEntity.
🌐
DZone
dzone.com › coding › languages › reactive programming in java: using the webclient class
Reactive Programming in Java: Using the WebClient Class
August 28, 2019 - WebClient webClient = WebClient.create(urlServer+"/server/"); Then, it executes the call of the type GET to the server passing the parameter QueryParam. In the end, when executing the function exchange, it will receive a Mono object containing ...
🌐
Jhu
jcs.ep.jhu.edu › legacy-ejava-springboot › coursedocs › content › html_single › springmvc-notes.html
Spring MVC
December 3, 2024 - However, it is common to want to have access to more detailed information. For example: ... Failure — was it a 400/BAD_REQUEST, 404/NOT_FOUND, 422/UNPROCESSABLE_ENTITY, or 500/INTERNAL_SERVER_ERROR? Spring can supply that additional information in a ResponseEntity<T>, supplying us with:
🌐
HowToDoInJava
howtodoinjava.com › home › spring webflux › spring boot webclient get example
Spring Boot WebClient GET Example
September 19, 2024 - It is part of the Spring WebFlux module and supports synchronous and asynchronous communications with external services. This tutorial discusses the basics of using WebClient in Spring Boot to make GET requests, as well as handling query parameters, headers, cookies, and errors.