问题描述
我有一个Spring集成流程,其中我监听一个通道并调用SOAP WS,然后将来自WS的响应放回到一个传出的通道中
return IntegrationFlows.from(CHANNEL)
.<byte[],String>transform(String::new)
.handle(
Ws.simpleOutboundGateway(template)
.uri(webServiceUrl )
)
.<String,byte[]>transform(String::getBytes)
. // send out the output topic
.get();
@Bean
public webservicetemplate webservicetemplate() {
webservicetemplate template = new webservicetemplate();
return template;
}
我将此流程用作集成测试的一部分,并且工作正常。
问题: 如果无法使用SOAP WS进行测试,则会显示以下内容
由以下原因引起:org.springframework.ws.client.WebServiceIOException:I / O错误:连接被拒绝:connect;嵌套的异常是java.net.ConnectException:连接被拒绝:connect 在org.springframework.ws.client.core.webservicetemplate.sendAndReceive(webservicetemplate.java:561)〜[spring-ws-core-3.0.10.RELEASE.jar:na] 在org.springframework.integration.ws.SimpleWebServiceOutboundGateway.doHandle(SimpleWebServiceOutboundGateway.java:120)〜[spring-integration-ws-5.3.2.RELEASE.jar:5.3.2.RELEASE] 在org.springframework.integration.ws.AbstractWebServiceOutboundGateway.handleRequestMessage(AbstractWebServiceOutboundGateway.java:224)〜[spring-integration-ws-5.3.2.RELEASE.jar:5.3.2.RELEASE] 在org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal
如何在此流程中大致捕获此错误,以及在肥皂基础WS响应中处理错误的最佳实践是什么? EX:服务不可用 SOAP请求/响应错误 ext
解决方法
通常取决于CHANNEL
上游的内容;您可以在启动流程的任何地方添加错误通道,也可以在网关中添加ExpressionEvaluatingRequestHandlerAdvice
。 Docs here。