问题
I am looking to make a SOAP call from spring reactive webclient. I couldn't find any documentation for it. Wondering what would the approach. Right now I am thinking
- Construct the SOAP message using JAXB on a separate thread pool
- Make the call by converting it to string via webclient
- Do convert back into java using jaxb on the way back on separate tp.
What are the downsides and any other approaches?
回答1:
You need to generate SOAP client as the stub classes with methods for asynchronous. JAX-WS API supports asynchronous invocation. Use wsiimport with enableAsyncMapping for generating method operationAsync(Input request, AsyncHandler asyncHandler);
AsyncHandler create using Mono.create()
Service service = new Service();
ServicePortType portType = service.getPortType();
public Mono<Output> operation(Input input) {
return Mono.create(sink ->
portType.operation(input, outputFuture -> {
try {
sink.success(outputFuture.get());
} catch (Exception e) {
sink.error(e);
}
})
);
}
and you get Mono reactivly
I have found suggest in the post https://blog.godatadriven.com/jaxws-reactive-client
来源:https://stackoverflow.com/questions/49685056/reactive-spring-webclient-making-a-soap-call