I have a spring integration flow where I listening to a channel and call a SOAP WS and and put back the response from the WS in to a outgoing channel
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;
}
I am using this flow as part of a integration test and this works fine.
questions : if I run the test with SOAP WS not been available I get the below
Caused by: org.springframework.ws.client.WebServiceIOException: I/O error: Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561) ~[spring-ws-core-3.0.10.RELEASE.jar:na] at org.springframework.integration.ws.SimpleWebServiceOutboundGateway.doHandle(SimpleWebServiceOutboundGateway.java:120) ~[spring-integration-ws-5.3.2.RELEASE.jar:5.3.2.RELEASE] at org.springframework.integration.ws.AbstractWebServiceOutboundGateway.handleRequestMessage(AbstractWebServiceOutboundGateway.java:224) ~[spring-integration-ws-5.3.2.RELEASE.jar:5.3.2.RELEASE] at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal
How do I capture this error/errors in general in this flow and what are best practices for error handling in soap base WS responses EX : Service not being available SOAP Request / Response errors ext
It generally depends on what is upstream of
CHANNEL
; you can add an error channel to whatever starts the flow, or you can add anExpressionEvaluatingRequestHandlerAdvice
to the gateway. Docs here.