现在我对SOAP和rest式服务之间的区别有了一点了解。

我的问题是什么时候应该使用SOAP,什么时候应该使用RESTful;当谈到性能/速度或请求处理时,哪一个“更好”?

我是第一次在RESTful (Java)实现它,我想知道更多关于它;我以前处理过SOAP。

这是这篇文章的后续问题。


当前回答

REST和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没有WSDL (Web描述语言)接口定义。 REST基于HTTP,但SOAP可以基于任何传输协议,如HTTP、FTP、SMTP、JMS等。

休息vs.肥皂

SOAP:

SOAP是运行在TCP/UDP/SMTP上的简单对象访问协议。 SOAP以XML格式读取和写入请求响应消息。 SOAP使用接口来定义服务。 SOAP更安全,因为它有自己的安全性和定义良好的标准。 SOAP遵循RPC和文档风格来定义web服务。 SOAP使用SOAP- ui作为客户端工具进行测试。

REST

► REST is representational state transfer that uses underlying HTTP protocols. ► REST is stateless. ► REST is an architectural style that is used to describe and define web services. ► REST can read and write request response messages in JSON/XML/Plain HTML. ► REST uses URI for each resource that is used in web service.A resource can be image text method etc. ► REST uses set of verbs, like HTTP's GET, POST, PUT, DELETE. ► REST is easy to develop and easy to manage as compared to SOAP UI. ► REST has light-weight client tools or plugins that can easily be integrated inside a browser. ► REST services are cacheable.

SOAP web服务总是执行POST操作,而使用REST,您可以选择特定的HTTP方法,如GET、POST、PUT和DELETE。

例如:要使用SOAP获取一个项目,您应该创建一个请求XML,但是在REST的情况下,您可以在URL本身中指定项目id。

REST和SOAP的区别: