Reactive Spring WebClient - 进行 SOAP 调用 [英] Reactive Spring WebClient - Making a SOAP call

查看:58
本文介绍了Reactive Spring WebClient - 进行 SOAP 调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从 Spring 反应式 Web 客户端进行 SOAP 调用.我找不到它的任何文档.想知道有什么方法.现在我在想

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. 在单独的线程池上使用 JAXB 构建 SOAP 消息
  2. 通过网络客户端将其转换为字符串来进行调用
  3. 在返回单独的 tp 的路上使用 jaxb 转换回 java.

缺点和其他方法是什么?

What are the downsides and any other approaches?

推荐答案

您需要生成 SOAP 客户端作为带有异步方法的存根类.JAX-WS API 支持异步调用.使用 wsiimportenableAsyncMapping 生成方法operationAsync(Input request, AsyncHandler asyncHandler);

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);

使用 Mono.create() 创建 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);
                   }
               })
            );
        }

你会反应性地获得 Mono

and you get Mono reactivly

我在 https://blog.godatadriven.com/jaxws-reactive 帖子中找到了建议-客户端

这篇关于Reactive Spring WebClient - 进行 SOAP 调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆