Both REST and SOAP Web Services for a single application
gradle, java, rest, soap, tomcat
Solution
In my experience, you can mix SOAP and REST in the same application if you're very careful about XML namespaces for JAXB. However, I wouldn't recommend it since updating one means risking the other's stability. Here is what I recommend...
- Setup a multi-project build in gradle
- Create three projects, one for the business logic, one for the REST interface, and one for the SOAP interface
- Modify the REST/SOAP interface to use common business logic project
- Deploy as two separate WARs
Should I accept a soap packet via the rest interface and parse the XML?
SOAP is a protocol and not just a format so this probably won't work with most (any?) frameworks.
Or can I setup a SOAP interface communicate with my REST interface and respond back?
You probably could at the expense of performance and/or maintainability.
Problem
We've build an application using Spring and deployed it with Tomcat. We have a working REST interface, however one of our clients only has a SOAP client. My understanding is that a SOAP web service and a REST web service cannot coexist on the same port or application. What are my options for accepting a SOAP request with as little development as possible. Should I accept a soap packet via the rest interface and parse the XML? Or can I setup a SOAP interface communicate with my REST interface and respond back? I'm using Gradle as my build tool. It would be nice to have the solution as part of a single WAR file