I have this RestTemplate which I want to migrate to WebFlux client:
RestTemplate restTemplate = new RestTemplate();
String url = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
ResponseEntity<Envelope> response = restTemplate.getForEntity(url, Envelope.class);
I tried this:
Boolean webClient = WebClient.builder()
.build()
.get()
.uri("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml")
.accept(MediaType.APPLICATION_XML)
.exchangeToMono(res -> Mono.just(res.statusCode().equals(HttpStatus.OK)))
.timeout(Duration.ofSeconds(2))
.block();
I’m not clear how I can get the response and read the response as JAVA DTO. Do you know how I have to implement his code?