Questions tagged [spring-webclient]

WebClient makes it possible to perform reactive non-blocking HTTP requests in Spring applications. Use this tag for any questions involving its usage.

992 questions
8
votes
1 answer

Spring web client return exception "Content type 'application/json' not supported for bodyType=[responseObject]

I use web client to post a third-party API, the third-part API return response like following: { "RetailTransactionGenericResponse": { "authID": 1146185, "product": { "amount": 20, "balance": 0, …
Vincent Zheng
  • 385
  • 1
  • 4
  • 19
8
votes
8 answers

spring-boot ReactiveClientRegistrationRepository not found

Environment: Spring Boot 2.3.1, Java 11 I have tried out a few things already (also comparing with the sample-app by spring), but so far I have been unsuccessful in creating a WebClient that requires a ReactiveClientRegistrationRepository. I get the…
marco
  • 163
  • 1
  • 1
  • 9
8
votes
0 answers

Is there a way to get the error response object when using generated webclient API to call a webservice that fails?

I have a REST service that takes an id and two strings as json and returns the id and the two strings concatenated as json. If there errors it can return statuscodes 400, 404 and 500 with a json error response in the body. The swagger.json file…
8
votes
1 answer

How to catch ConnectionException in Spring WebClient?

I have the following error handling in RestTemplate: try { restTemplate.postForObject(..); } catch (ResourceAccessException e) { throw new CustomException("host is down"); } Question: how can I achieve the same with spring WebClient? try { …
membersound
  • 81,582
  • 193
  • 585
  • 1,120
8
votes
2 answers

Using WebClient to propagate request headers received in a Spring Webflux applications to downstream services

I have two kinds of Webflux applications, annotation-based and route-based. These applications are called with a set of headers, some of which (Open Tracing) I need to propagate in downstream calls using WebClient. If these were normal Spring WebMvc…
codependent
  • 23,193
  • 31
  • 166
  • 308
8
votes
3 answers

download a file using Angular JS and a Spring-based RESTful web service

I'm using Spring boot and Angular JS . I have a Spring REST Controller that I use to download a File. when I call it using http://localhost:8080/download it works and the file is downloaded. Now I have a button ,when I click on it , I the file…
Yuri
  • 447
  • 3
  • 9
  • 19
7
votes
2 answers

Getting the response body in error case with Spring WebClient

I am trying to replace the existing client code with RestTemplate with a WebClient. For that reason, most of the calls need to be blocking, so that the main portion of the application does not need to change. When it comes to error handling this…
hotzst
  • 7,238
  • 9
  • 41
  • 64
7
votes
1 answer

javax.net.ssl.SSLException: SSLEngine closed already SSLEngine closed already in webclient (Springboot)

I am using webclient in springboot application to call a external restful webservice. getting this exception intermittently. javax.net.ssl.SSLException: SSLEngine closed already SSLEngine closed already I see below warning in logs before getting…
7
votes
3 answers

Webflux Webclient escape slash in URL

I need to include a slash in an URL to access RabbitMQ API and I'm trying to fetch data using WebClient: WebClient.builder() .baseUrl("https://RABBIT_HOSTNAME/api/queues/%2F/QUEUE_NAME") .build() .get().exchange(); When I replace /…
Michael Dz
  • 3,655
  • 8
  • 40
  • 74
7
votes
2 answers

Spring WebClient - How to handle error scenarios

We're using org.springframework.web.reactive.function.client.WebClient with reactor.netty.http.client.HttpClient as part of Spring 5.1.9 to make requests using the exchange() method. The documentation for this method highlights the following: ...…
user1491636
  • 2,355
  • 11
  • 44
  • 71
7
votes
2 answers

How to validate bean on Spring's WebClient?

I guess the answer is no, as all references to Bean Validation in the documentation are related to the server side. Is there any support for Bean Validation on the client's side? So that I can validate my entities before even sending them to the…
antonro
  • 449
  • 2
  • 4
  • 10
7
votes
2 answers

How to log spring-webflux WebClient request + response details (bodies, headers, elasped_time)?

Basically, I want to log a request/response informations in one log containing bodies/headers with a Spring WebClient. With Spring RestTemplate we can do it with a ClientHttpRequestInterceptor. I find about ExchangeFilterFunction for Spring…
7
votes
1 answer

Is Spring webclient non-blocking client?

I don't understand reactive webclient works. It says that spring webclient is non-blocking client, but this webclient seems waiting signal onComplete() from remote api, then it can process each item that emitted from the remote api. I'm expecting…
Anton Tb
  • 417
  • 1
  • 5
  • 8
6
votes
0 answers

Spring Webflux migrate WebClient.exchange() to WebClient.exchangeToMono() with DataBuffer

While upgrading one project to spring webflux 5.3.3 I noticed that the Webclient.exchange method was getting deprecated (link). I already read the question Spring WebFlux 5.3.0 - WebClient.exchangeToMono() and I have a question regarding using…
Spucman
  • 61
  • 1
  • 3
6
votes
0 answers

Spring Boot WebClient XML

My spring boot application wants to use Webclient to make an http request (XML request body) and receives XML response. Hence I created another spring boot application with jackson-dataformat-xml and created an endpoint to receive and return XML as…
1 2
3
65 66