用于单个应用程序的REST和SOAP Web服务 [英] Both REST and SOAP Web Services for a single application
问题描述
我们使用Spring构建了一个应用程序,并将其与Tomcat一起部署。我们有一个可用的REST接口,但是我们的一个客户端只有一个SOAP客户端。
我的理解是SOAP Web服务和REST Web服务不能共存于同一端口或应用程序。
接受SOAP请求的选择尽可能少。我应该通过其余接口接受一个soap包并解析XML吗?或者我可以设置一个SOAP接口与我的REST接口进行通信并进行响应?
我使用Gradle作为构建工具。将解决方案作为单个WAR文件的一部分是很好的
根据我的经验,您可以在同一个应用程序中混合SOAP和REST,如果您非常小心JAXB的XML名称空间。但是,我不会推荐它,因为更新一个意味着冒着对方的稳定性。这是我推荐的...
- 在Gradle中设置多项目构建 创建三个项目,一个用于业务逻辑,一个用于REST界面,另一个用于SOAP接口
- 修改REST / SOAP接口以使用通用业务逻辑项目
- 部署为两个单独的WAR
- 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
ol>
我应该通过其他接口接受一个soap包并解析XML吗?
SOAP是一种协议,不仅仅是一种格式,所以这可能不适用于大多数(任何?)框架。
或者我可以设置一个SOAP接口与我的REST接口进行通信并进行响应吗?
您可能会牺牲性能和/或可维护性。
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
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...
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.
这篇关于用于单个应用程序的REST和SOAP Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!