I'm using WebClient (SpringBoot 2.0.2.RELEASE) to send a POST with SOAP request, but it is missing "Content-Length" header required by the legacy API.
Is it possible to configure WebClient to include "Content-Length" header?
There is an Spring Framework Issue resolved and introduced for EncoderHttpMessageWriter in SpringBoot 2.0.1, but it seems not to work for JAXB.
I tried to use BodyInserters
:
webClient.post().body(BodyInserters.fromObject(request)).exchange();
and syncBody
:
webClient.post().syncBody(request).exchange();
None of them worked for WebClient
. Though, when RestTemplate
is used, Content-Length is set and API responds with success
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…