【发布时间】:2019-09-08 19:31:34
【问题描述】:
我已成功建立与沙盒服务器的 SSL 连接,并通过应用内容类型 MediaType.APPLICATION_XML 将对象作为序列化 XML 对象发送。但是,这还不够,因为目标服务仅支持 SOAP 并希望消息正确包装在信封中。
final var webClient = WebClient.builder()
.baseUrl(fmdConfiguration.getSinglePackUrl())
.clientConnector(connector)
.exchangeStrategies(exchangeStrategies)
.filter(logResponseStatus())
.filter(logRequest())
.build();
return webClient
.method(GET)
.contentType(MediaType.APPLICATION_XML)
.body(BodyInserters.fromObject(request))
.retrieve()
.bodyToMono(SinglePackPingResponse.class);
这是来自服务的响应:
Unable to create envelope from given source because the root element is not named "Envelope"
很遗憾,WebClient 不支持媒体类型 application/soap+xml。当我尝试使用它时,WebClient 会抛出以下错误:
org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/soap+xml;charset=UTF-8' not supported for bodyType=eu.nmvs.SinglePackPingRequest
at org.springframework.web.reactive.function.BodyInserters.unsupportedError(BodyInserters.java:300)
【问题讨论】:
-
你能发一个mcve吗? “为什么我的代码不起作用”类型的问题很难用上面的 sn-ps 来回答。
-
@Andras,你成功了吗?
-
@AmosKosgei 不,我应用了blog.godatadriven.com/jaxws-reactive-client中描述的方法
标签: spring soap spring-webflux project-reactor reactor-netty