0

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

SJay
  • 15
  • 4

1 Answers1

0

It generally depends on what is upstream of CHANNEL; you can add an error channel to whatever starts the flow, or you can add an ExpressionEvaluatingRequestHandlerAdvice to the gateway. Docs here.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Thanks Gary, CHANNEL in this case is a kafka topic. what I am trying to do is capture the "WebServiceIOException: I/O error: Connection refused", exception and construct a response message with it and put it back to a outgoing kafka topic. Appreciate if you could point me to an example of what you mentioned above. – SJay Oct 13 '20 at 13:45