I tried to make a SOAP call from spring reactive webclient.
the ConfirmPayer10
, ConfirmPayer10Response
and ObjectFactory
classes i generated from wsdl file by the maven-jaxb2-plugin
plugin.
for the encoder and decoder config, i get the same from here and here
ConfirmPayer10 confirmPayer10 = new ConfirmPayer10();
confirmPayer10.setArg0(confirmPayerRq);
final JAXBElement<ConfirmPayer10> jAXBElement = new ObjectFactory().createConfirmPayer10(confirmPayer10);
webClient.post().uri( url )
.contentType(MediaType.TEXT_XML)
.body( Mono.just(jAXBElement) , new ParameterizedTypeReference<JAXBElement<ConfirmPayer10>>() {})
.retrieve()
.onStatus(
HttpStatus::isError,
clientResponse ->
clientResponse
.bodyToMono(String.class)
.flatMap(
errorResponseBody ->
Mono.error(
new ResponseStatusException(
clientResponse.statusCode(),
errorResponseBody))))
.bodyToMono(new ParameterizedTypeReference<JAXBElement<ConfirmPayer10Response>>() {})
.doOnSuccess( (res) -> {
System.out.println("success");
System.out.println("capital : " + res.getValue().getReturn().getRqUID());
})
.doOnError(ResponseStatusException.class, error -> {
System.out.println( "error : "+ error );
})
.doOnError(Exception.class, ( Exception error ) -> {
System.out.println( "error : "+ error );
error.printStackTrace();
}).subscribe();
the problem is that i have this error
org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'text/xml' not supported for bodyType=javax.xml.bind.JAXBElement< ConfirmPayer10 >