Reactive Spring WebClient - Making a SOAP call

余生颓废 提交于 2020-02-26 09:19:12

问题


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:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!