Class WebClientAdapter
java.lang.Object
org.springframework.web.service.invoker.AbstractReactorHttpExchangeAdapter
org.springframework.web.reactive.function.client.support.WebClientAdapter
- All Implemented Interfaces:
HttpExchangeAdapter, ReactorHttpExchangeAdapter
ReactorHttpExchangeAdapter that enables an HttpServiceProxyFactory
to use WebClient for request execution.
Use static factory methods in this class to create an
HttpServiceProxyFactory configured with a given WebClient.
- Since:
- 6.0
- Author:
- Rossen Stoyanchev
-
Method Summary
Modifier and TypeMethodDescriptionstatic WebClientAdapterCreate aWebClientAdapterfor the givenWebClientinstance.exchangeForBodilessEntityMono(HttpRequestValues requestValues) Variant ofReactorHttpExchangeAdapter.exchangeForMono(HttpRequestValues)with additional access to the response status and headers.<T> Flux<T> exchangeForBodyFlux(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Perform the given request and decode the response content to a stream with elements of the given type.<T> Mono<T> exchangeForBodyMono(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Perform the given request and decode the response content to the given type.<T> Mono<ResponseEntity<Flux<T>>> exchangeForEntityFlux(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Variant ofReactorHttpExchangeAdapter.exchangeForBodyFlux(HttpRequestValues, ParameterizedTypeReference)with additional access to the response status and headers.<T> Mono<ResponseEntity<T>> exchangeForEntityMono(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Variant ofReactorHttpExchangeAdapter.exchangeForBodyMono(HttpRequestValues, ParameterizedTypeReference)with additional access to the response status and headers.exchangeForHeadersMono(HttpRequestValues requestValues) Perform the given request, release the response content, and return the response headers.exchangeForMono(HttpRequestValues requestValues) Perform the given request, and release the response content, if any.newRequest(HttpRequestValues values) Build a request from the givenHttpRequestValues.booleanWhether the underlying client supports use of request attributes.
-
Method Details
-
supportsRequestAttributes
public boolean supportsRequestAttributes()Description copied from interface:HttpExchangeAdapterWhether the underlying client supports use of request attributes. -
exchangeForMono
Description copied from interface:ReactorHttpExchangeAdapterPerform the given request, and release the response content, if any.- Parameters:
requestValues- the request to perform- Returns:
Monothat completes when the request is fully executed and the response content is released.
-
exchangeForHeadersMono
Description copied from interface:ReactorHttpExchangeAdapterPerform the given request, release the response content, and return the response headers.- Parameters:
requestValues- the request to perform- Returns:
Monothat returns the response headers the request is fully executed and the response content released.
-
exchangeForBodyMono
public <T> Mono<T> exchangeForBodyMono(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Description copied from interface:ReactorHttpExchangeAdapterPerform the given request and decode the response content to the given type.- Type Parameters:
T- the type the response is decoded to- Parameters:
requestValues- the request to performbodyType- the target type to decode to- Returns:
Monothat returns the decoded response.
-
exchangeForBodyFlux
public <T> Flux<T> exchangeForBodyFlux(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Description copied from interface:ReactorHttpExchangeAdapterPerform the given request and decode the response content to a stream with elements of the given type.- Type Parameters:
T- the type the response is decoded to- Parameters:
requestValues- the request to performbodyType- the target stream element type to decode to- Returns:
Fluxwith decoded stream elements.
-
exchangeForBodilessEntityMono
Description copied from interface:ReactorHttpExchangeAdapterVariant ofReactorHttpExchangeAdapter.exchangeForMono(HttpRequestValues)with additional access to the response status and headers. -
exchangeForEntityMono
public <T> Mono<ResponseEntity<T>> exchangeForEntityMono(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Description copied from interface:ReactorHttpExchangeAdapterVariant ofReactorHttpExchangeAdapter.exchangeForBodyMono(HttpRequestValues, ParameterizedTypeReference)with additional access to the response status and headers. -
exchangeForEntityFlux
public <T> Mono<ResponseEntity<Flux<T>>> exchangeForEntityFlux(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Description copied from interface:ReactorHttpExchangeAdapterVariant ofReactorHttpExchangeAdapter.exchangeForBodyFlux(HttpRequestValues, ParameterizedTypeReference)with additional access to the response status and headers. -
newRequest
Build a request from the givenHttpRequestValues.- Parameters:
values- the values to use- Returns:
- the request spec
- Since:
- 7.0.6
-
create
Create aWebClientAdapterfor the givenWebClientinstance.- Parameters:
webClient- the client to use- Returns:
- the created adapter instance
- Since:
- 6.1
-