Thursday, May 16, 2019

Spring Integration demo for exposing a SOAP Web Service which consumes another Web Service

Even in 2019, we often still need to develop SOAP based web services due to the need to integrate with legacy applications still using them. It was hard to find code samples that use Spring Integration with Java DSL using Spring Boot to expose/consume SOAP based web services. I put together an example which uses all of the above:
  1. initial branch shows an initial implementation of a web service exposed using spring-ws, Spring Boot and Java DSL. This was loosely based on the "Producing a SOAP web service" getting started guide.
  2. inboundgateway branch takes the initial branch and converts it to using Spring Integration classes (i.e. MarshallingWebServiceInboundGateway and MessageChannel). Credit to tomask79's spring boot web service integration repo which was one of few sample codes I found to expose a SOAP service using Spring Integration with Java DSL. In particular this commit will show you how easy it is to go from Spring-WS to a Spring Integration implementation.
  3. outboundgateway branch introduces a MarshallingWebServiceOutboundGateway to call into another SOAP web service to get order details. It also introduces the use of @EnableIntegrationGraphController annotation to build a visualization of the flow using spring-flow-si

The visualization tool output is fairly impressive:


However, I'm not convinced Spring Integration is the best fit for this particular use case, i.e. integration flows primarily between web services and some JMS services. Here are some of the things I did not like:
  1. Code flow becomes hard to follow. Flows are connected primarily via channels. I introduced a ChannelNames class with constants to make it easier to follow the flow, but even with this, I had to find usages of the constant and then navigate to those classes.
  2. The request/response web service methods had to be decoupled into a "request" (request channel) and "response" (reply channel) method. I posted this question in StackOverflow and even though this method could be combined using a MessageGateway, it is not the ideal way of implementing this with Spring Integration. Even with the diagram above, you cannot tell that orderInboundGateway is a 2-way flow, instead it appears a one-way flow.
Don't get me wrong, I liked several aspects of Spring Integration and I would find it useful for other scenarios, but it seems for this one, the complexity introduced outweighs some of the benefits. 

Please chime in the comments if you've successfully implemented similar scenarios with Spring Integration!

No comments: