【发布时间】:2015-10-12 18:46:34
【问题描述】:
肥皂和休息有什么区别
在设置一些新的 Web 服务或集成环境时,会多次提出这个问题。 哪个更好。
我知道一些基本的区别,下面提到:
(1)Rest is based on http protocol (get,put,post,delete) , treating everything as a resource.
whereas SOAP is transport agnostic
(2)Soap works only with xml , Rest works with json/xml both.
(3)rest do not provide schema definition when implemented as json,
Soap will always provide schema definitions.
It will be easy to understand request/response schema and
their data type constraints when viewing schema information via WSDL by any client.
(4)The step of wsdl creation makes it difficult to make any changes in your
schema classes while implementing in soap.
Rest implementation is quite easy, we just need to make changes in pojo classes.
(5)Soap provides default error handling via faults.
We can also create our own custom faults.
In Rest we need to handle all error messages explicitly.
(6)Soap provides SoapHandler to intercept request both at client/server side
with both request/response.
we can use filters of j2ee or interceptors of Spring to intercept calls.
(7)Soap is fixed defined set of protocol, whereas rest is architectural style.
While implementing REST, developers can follow any rule,
for example
not using http protocol in well defined way.
While in Soap message part is defined as envelope.
one envelope=header+body+fault+attachment
我仍在学习这些概念,还没有研究过这些服务在 rest 和 soap 中的安全性。
在我看来,最好的答案是“这取决于要求”。
现在我想知道哪些要求有利于哪些实施?
什么时候应该首选肥皂,什么时候应该休息?请举例说明。
如果我在某处错了,请纠正我。
谢谢
【问题讨论】:
-
这主要是基于意见。这个问题没有单一的答案。
标签: java web-services rest soap