0

Tech Stack: Java 1.6, JPA (Hibernate 3), Spring 3, Oracle 11g

Hello,

In one of my projects, we have to create a number of web services. These web services are like 'create application' and 'udpate application'.

For creating an application, the input data (request XML) is around 90-100 lines.

In my view I should be using SOAP\XML webservice (Spring), but my company has decided to go forward with REST (JAX-RS).

I think it will be difficult for client to create such request without any formal contract.

Or do you think REST will serve the purpose?

Thanks, Adi

4

1 回答 1

1

REST 比 SOAP 灵活得多。使用 REST 服务,您可以将响应返回为 XML/JSON/HTML,而在 SOAP 中它通常只是 XML。

REST 也使用普通 HTTP,这与扩展 HTTP 的 SOAP 不同。

因此,您的公司做出了正确的选择。关于答案的格式,如果是 JSON,可以使用Gson之类的库来转换消息。您需要编写一份描述不同链接及其输入/输出的文档(例如,查看此处)

如果它是 XML,那么您只需要一个用于请求/响应的 XSD,然后再次使用像XmlBeans这样的 FW来编组/解组请求/响应。在这种情况下,只需将 XSD 和上述文档提供给客户端即可。

于 2012-07-22T14:13:55.530 回答