`
leonzhx
  • 浏览: 796620 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

REST Vs SOAP, The Difference Between Soap And Rest

阅读更多

Zz from http://spf13.com/post/soap-vs-rest

Someone asked me a question today “Why would anyone choose SOAP (Simple Object Access Protocol) instead of REST (Representational State Transfer)?” My response: “The general rule of thumb I’ve always heard is ‘Unless you have a definitive reason to use SOAP use REST’”. He asked “what’s one reason?” I thought about it for a minute and honestly answered that I haven’t ever come across a reason. My background is building great internet companies.

While he seemed satisfied, I wasn’t very happy with that answer, I did some homework and here’s my summary on REST versus SOAP, the difference between SOAP and REST and why anyone would choose SOAP. As usual, with competing technologies both have value, the challenge is to know when to use each one (spoiler: luckily the answer is almost always REST).

I’m clearly boiling down a somewhat so please don’t flame me for simplifying things, but feel free to provide any corrections you feel are necessary.

Definitions

REST

RESTs sweet spot is when you are exposing a public API over the internet to handle CRUD operations on data. REST is focused on accessing named resources through a single consistent interface.

SOAP

SOAP brings it’s own protocol and focuses on exposing pieces of application logic (not data) as services. SOAP exposes operations. SOAP is focused on accessing named operations, each implement some business logic through different interfaces.

Though SOAP is commonly referred to as “web services” this is a misnomer. SOAP has very little if anything to do with the Web. REST provides true “Web services” based on URIs and HTTP.

By way of illustration here are few calls and their appropriate home with commentary.

getUser(User);

This is a rest operation as you are accessing a resource (data).

switchCategory(User, OldCategory, NewCategory)

This is a SOAP operation as you are performing an operation.

Yes, either could be done in either SOAP or REST. The purpose is to illustrate the conceptual difference.

Why REST?

Here are a few reasons why REST is almost always the right answer.

Since REST uses standard HTTP it is much simpler in just about ever way. Creating clients, developing APIs, the documentation is much easier to understand and there aren’t very many things that REST doesn’t do easier/better than SOAP.

REST permits many different data formats where as SOAP only permits XML. While this may seem like it adds complexity to REST because you need to handle multiple formats, in my experience it has actually been quite beneficial. JSON usually is a better fit for data and parses much faster. REST allows better support for browser clients due to it’s support for JSON.

REST has better performance and scalability. REST reads can be cached, SOAP based reads cannot be cached.

It’s a bad argument (by authority), but it’s worth mentioning that Yahoo uses REST for all their services including Flickr and del.ici.ous. Amazon and Ebay provide both though Amazon’s internal usage is nearly all REST source. Google used to provide only SOAP for all their services, but in 2006 they deprecated in favor of REST source. It’s interesting how there has been an internal battle between rest vs soap at amazon. For the most part REST dominates their architecture for web services.

Why SOAP?

Here are a few reasons you may want to use SOAP.

WS-Security

While SOAP supports SSL (just like REST) it also supports WS-Security which adds some enterprise security features. Supports identity through intermediaries, not just point to point (SSL). It also provides a standard implementation of data integrity and data privacy. Calling it “Enterprise” isn’t to say it’s more secure, it simply supports some security tools that typical internet services have no need for, in fact they are really only needed in a few “enterprise” scenarios.

WS-AtomicTransaction

Need ACID Transactions over a service, you’re going to need SOAP. While REST supports transactions, it isn’t as comprehensive and isn’t ACID compliant. Fortunately ACID transactions almost never make sense over the internet. REST is limited by HTTP itself which can’t provide two-phase commit across distributed transactional resources, but SOAP can. Internet apps generally don’t need this level of transactional reliability, enterprise apps sometimes do.

WS-ReliableMessaging

Rest doesn’t have a standard messaging system and expects clients to deal with communication failures by retrying. SOAP has successful/retry logic built in and provides end-to-end reliability even through SOAP intermediaries.

Summary

 

In Summary, SOAP is clearly useful, and important. For instance, if I was writing an iPhone application to interface with my bank I would definitely need to use SOAP. All three features above are required for banking transactions. For example, if I was transferring money from one account to the other, I would need to be certain that it completed. Retrying it could be catastrophic if it succeed the first time, but the response failed.

分享到:
评论

相关推荐

    REST 基础(二):Web 服务编程,REST 与 SOAP

    在本篇博客“REST基础(二):Web服务编程,REST与SOAP”中,我们将深入探讨两种主要的Web服务编程模型:Representational State Transfer (REST) 和 Simple Object Access Protocol (SOAP)。这两种技术都是用于构建...

    SOAP vs REST WebService

    SOAP and REST WebService 的比较分析,SOAP and REST WebService 的比较分析

    soap vs rest 图对比

    对比soap和rest的区别,从架构 应用 传输 数据承载区分

    soap_to_rest_node:将SOAP转换为REST请求的项目

    【标题】"soap_to_rest_node:将SOAP转换为REST请求的项目"是一个旨在帮助开发者将传统的SOAP(简单对象访问协议)服务转换为更现代、更易于使用的REST(表述性状态转移)API的开源项目。该项目主要使用JavaScript...

    SOAP to REST_library_

    标题中的"SOAP to REST_library_"表明了我们讨论的主题是关于将SOAP(Simple Object Access Protocol)服务转换为REST(Representational State Transfer)服务的库或工具。SOAP是一种基于XML的协议,用于在Web上...

    REST与SOAP WEB SERVICE的区别1

    【REST与SOAP WEB SERVICE的区别】 在Web服务领域,REST(Representational State Transfer)和SOAP(Simple Object Access Protocol)是两种常见的通信方式,它们各有特点,适用于不同的场景。REST以其简洁和直观...

    面向服务的架构SOA分为2种 SOAP即Webservice和REST

    "rest(一种软件架构风格)_百度百科.url"和"SOA接口的两种常用实现比较:SOAP(WebService) vs REST(GET,POST).url"可能是链接到更详细的参考资料,它们提供了关于REST架构风格的深入介绍,以及SOAP和REST在实际应用...

    rest soap cxf webservice maven springmvc

    在IT行业中,REST和SOAP是两种常见的Web服务接口设计风格,而CXF是一个流行的开源框架,用于构建和消费这两种服务。Maven是一个项目管理和综合工具,SpringMVC则是Spring框架的一部分,专门用于构建Web应用程序。...

    soap和rest比较

    ### SOAP与REST的比较 #### 一、引言 在当今的互联网技术中,Web服务作为连接不同系统间的关键桥梁,扮演着极其重要的角色。在众多实现Web服务的技术方案中,SOAP(Simple Object Access Protocol)与REST...

    什么是REST,符合REST的API叫RESTful 两种SOA接口实现:SOAP(WebService) vs REST

    文件`rest(一种软件架构风格)_百度百科.url`和`SOA接口的两种常用实现比较:SOAP(WebService) vs REST(GET,POST).url`分别指向了关于REST和SOAP/REST比较的参考资料,它们可以进一步深入理解这两种接口实现的区别...

    Boomerang - SOAP & REST Client-7.7.6.zip

    名称:Boomerang - SOAP & REST Client -------------------- 版本:7.7.6 作者:https://boomerangapi.com/ 分类:开发者工具 -------------------- 概述:无缝集成和测试 SOAP 和 REST 服务。 描述: 无缝集成和...

    soap和rest的应用flickr(一个照片管理网站的源代码)

    在IT行业中,SOAP(Simple Object Access Protocol)和REST(Representational State Transfer)是两种常见的Web服务接口设计风格,用于构建分布式系统,使不同应用程序能够相互通信。本项目"soap和rest的应用flickr...

    Boomerang - SOAP & REST Client 6.1.0.0.zip

    浏览器插件,无缝集成和测试 SOAP 和 REST 服务。 Boomerang - SOAP & REST Client 6.1.0.0 for Chrome。 压缩包内包括 crx、pem、rar 等文件,谷歌内核的浏览器可直接拖放 crx 文件安装,如果提示“该扩展程序未列...

    基于WCF创建SOAP和REST服务源码

    在IT行业中,Windows Communication Foundation(WCF)是微软推出的一种用于构建分布式应用程序的服务框架,它集成了多种通信协议,如SOAP(简单对象访问协议)和REST(Representational State Transfer)。...

    REST WebService与SOAP WebService的比较.docx

    REST(Representational State Transfer,表述性状态转移)和SOAP(Simple Object Access Protocol,简单对象访问协议)是两种主要的Web服务技术,它们在Web服务领域中有着不同的设计理念和应用场景。理解两者的差异...

    论文研究-Application of interface design between DSP2812 and serial EEPROM in the further development of the fuel cell engine controller.pdf

    DSP2812与串行EEPROM的接口设计在燃料电池发动机控制器二次开发中的应用,童芳菲,全书海,在燃料电池发动机控制系统中一些状态参数往往不仅要求能够做到在线修改,而且希望这些修改过的参数在断电时能够继续保持,以...

Global site tag (gtag.js) - Google Analytics