1
votes

We are currently using Spring MVC to implement REST services. We need to expose a subset of these service implementations as SOAP.

I looked into apache camel documentation to see if there is any such direct support. From the documentation it seems that camel can probably do it but for only services implemented through Apache CXF. Before jumping into a conclusion I like to know if it's possible with Spring MVC implemented REST services as well.

  • Does camel support exposing Spring MVC implemented REST services as SOAP services
  • If yes, can you point me to some documentation.
  • If not, any suggestions on implementing SOAP wrappers for Spring MVC implemented REST services.
2
Does your current implementation use Camel? Or are you currently using straight Spring MVC and thinking about using Camel to achieve the SOAP interface? - Roy Truelove
Our current implementation doesn't use camel. It uses simple Spring MVC for implementing REST services. - Siva

2 Answers

3
votes

First, there is no obvious way to automatically proxy between SOAP and REST.

REST is all about data/resources (in all shapes and colours) and very few operations, SOAP is all about operations with XML defined data.

But it should be rather straight forward to consume SOAP messages with Camel (for instance using Spring WS).

Then you could either work with raw XML (XPATH or XSLT) or perhaps perfeered by unmarshall it with JAXB to Java objects. This could be rather automated. See (http://camel.apache.org/spring-ws-example.html for a Spring WS, Camel and JAXB example). I also suggest that you use maven-jaxb2-plugin to generate the Java objects with JAXB based on the SOAP schemas.

Then you need some kind of lookup table to route between SOAP endpoints/methods/soap actions to REST services. This is a lot dependent on the structure of your REST services. Then calling RESTful resources with Camel should be trivial. Consider it HTTP or REST, whatever you like.

What you have to consider, and it is perhaps the most important part in this scenario, is if your REST services featuers other payload encoding than XML, for instance JSON. Then a mapping between XML and JSON has to be done. There is no real standard for that, but Camel can simplify that work. Camel will even feature an automatic conversion in the next release 2.10 (https://issues.apache.org/jira/browse/CAMEL-4930).

1
votes

I guess one possible option for you is to use any ESB and implement a proxy providing a SOAP interface for the REST APIs.

Basically the ESB acts as a proxy receiving SOAP messages and converts the format to REST to talk to the existing REST API and converts the response received back to SOAP to respond to the client.

This is a very common use case with most of the ESBs, I am sure Camel can do that too, how ever you may want to look at other ESBs like UltraESB too and take the decision if you are not bound to Camel already.