现在我对SOAP和rest式服务之间的区别有了一点了解。
我的问题是什么时候应该使用SOAP,什么时候应该使用RESTful;当谈到性能/速度或请求处理时,哪一个“更好”?
我是第一次在RESTful (Java)实现它,我想知道更多关于它;我以前处理过SOAP。
这是这篇文章的后续问题。
现在我对SOAP和rest式服务之间的区别有了一点了解。
我的问题是什么时候应该使用SOAP,什么时候应该使用RESTful;当谈到性能/速度或请求处理时,哪一个“更好”?
我是第一次在RESTful (Java)实现它,我想知道更多关于它;我以前处理过SOAP。
这是这篇文章的后续问题。
当前回答
REST stands for representational state transfer whereas SOAP stands for Simple Object Access Protocol. SOAP defines its own security where as REST inherits security from the underlying transport. SOAP does not support error handling, but REST has built-in error handling. REST is lightweight and does not require XML parsing. REST can be consumed by any client, even a web browser with Ajax and JavaScript. REST consumes less bandwidth, it does not require a SOAP header for every message. REST is useful over any protocol which provide a URI. Ignore point 5 for REST as mentioned below in the picture.
其他回答
REST几乎总是更快。SOAP的主要优点是它提供了一种机制,可以让服务向客户端描述自己,并宣传它们的存在。
REST轻量级得多,几乎可以使用任何工具实现,从而降低带宽,缩短学习曲线。然而,客户端必须知道要发送什么以及期望发送什么。
通常,当您向外界发布复杂或可能更改的API时,SOAP将更有用。除此之外,REST通常是更好的选择。
REST没有WSDL (Web描述语言)接口定义。 REST基于HTTP,但SOAP可以基于任何传输协议,如HTTP、FTP、SMTP、JMS等。
REST stands for representational state transfer whereas SOAP stands for Simple Object Access Protocol. SOAP defines its own security where as REST inherits security from the underlying transport. SOAP does not support error handling, but REST has built-in error handling. REST is lightweight and does not require XML parsing. REST can be consumed by any client, even a web browser with Ajax and JavaScript. REST consumes less bandwidth, it does not require a SOAP header for every message. REST is useful over any protocol which provide a URI. Ignore point 5 for REST as mentioned below in the picture.
REST是一种体系结构。 REST将给出人类可读的结果。 REST是非状态的。 REST服务很容易被缓存。
SOAP是一种协议。它可以运行在JMS、FTP和HTTP之上。
SOAP
简单对象访问协议(SOAP)是一种标准的XML语言,定义了消息体系结构和消息格式。Web服务使用它。它包含操作的描述。
WSDL是一种基于xml的语言,用于描述Web服务以及如何访问它们。它将运行在SMTP, HTTP, FTP等。它需要中间件支持和定义良好的机制来定义WSDL+XSD和WS-Policy等服务。 SOAP将返回基于XML的数据
REST
具象状态传输(RESTful) web服务。它们是第二代Web服务。
基于rest的web服务通过HTTP而不是基于soap的服务进行通信,并且不需要XML消息或WSDL服务api定义。对于REST中间件不需要,只需要HTTP支持。它是一个WADL标准,REST可以返回XML、纯文本、JSON、HTML等。