Reactive Spring WebClient - Making a SOAP call

2020-06-01 08:11发布

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

  1. Construct the SOAP message using JAXB on a separate thread pool
  2. Make the call by converting it to string via webclient
  3. Do convert back into java using jaxb on the way back on separate tp.

What are the downsides and any other approaches?

1条回答
Melony?
2楼-- · 2020-06-01 08:55

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

查看更多
登录 后发表回答