`
mathsfan
  • 浏览: 579360 次
  • 性别: Icon_minigender_1
  • 来自: 浙江省杭州市
社区版块
存档分类
最新评论

关于REST(转)

阅读更多
REpresentational State Transfer(REST)  代表性状态传输
REST是WEB服务的一种架构,简单的说就是通过HTTP协议提供XML数据。最常见的应用就是RSS.
REST的基本规则:
1、所有可区分的实体都是资源,这些资源可以是一个XML文档,或者是一个HTML页面来进行描述(Representation ). 补充:鉴于xml的结构化,跨平台等等特性,建议所有的资源都通过xml进行描述
2、每个资源通过一个唯一的URL进行定义
3、WEB服务返回的数据应该包含其它数据的链接地址(URL). 也就是说,把要提供的数据设计成一个信息网络
4、服务提供方维护一组资源,并公开一组基本操作来执行以下任务:
        检索资源(HTTP GET)
        创建新资源 (HTTP POST)
        修改资源 (HTTP POST)
        删除资源  (HTTP POST)




REST与SOAP(Simple Object Access Protocal, 简单对象访问协议)的比较
     1、从基本原理层次上来讲,REST适合于面向资源的服务,服务提供方维护一组资源,并公开一组基本操作来执行以下任务:

      检索资源

      修改资源

      创建新资源

      删除资源

     资源是他们关心的中心。

    而SOAP更适合于面向活动的服务,客户端请求的每个活动的操作是他们关心的中心。

   2、从使用上来说,REST更简单,更快速,而SOAP在安全性方面会有更多更好的方案供选择

Flickr就是采用REST方式提供的 WEB SERVICES


而Amazon95%的服务也采用该方式

了解更多的WEB服务和SOAP 到http://www-128.ibm.com/developerworks/cn/webservices/







下面的文章介绍的比较详细:

来源:http://searchwebservices.techtarget.com/qna/0,289202,sid26_gci823342,00.html

REST could burst SOAP's bubble



Simple Object Access Protocol (SOAP), today's de facto Web services communications protocol, and has come a long way since Microsoft first developed it in 1999. However, the latest Web services fad is an architecture called REST, or representational state transfer. First coined in a popular dissertation by eBuilt's Roy Fielding, REST is a distributed computing framework that stresses component interaction and scalability. SearchWebServices spoke with Roy Hoobler, director of Internet technologies for Net@Work Inc., about REST and its potential impact on Web services.

Is there a simple way to explain REST?
Hoobler: Here's the way (Amazon.com) is using REST. Typically, if I'm building an XML application, usually I have to have the XML file on my machine. However, with most XML apps, that doesn't have to be the case because you can access the XML file through any valid URL. For instance, I can go out to your Web site and get an XML file and parse it on my machine.

If it's in a database, it has to be a local database. I can't connect directly to Amazon's database, and there's no way they're going to let me. So, they might have a SOAP service, or they might do a query through HTTP, which is what they're doing. What they're doing (with REST) is building an XML document on the fly and returning (database data) via HTTP. I can use that on my system, save it and process it. There's a lot I can do with that and I don't need SOAP, and I don't have to program anything.



 


Is it really that simple?
Hoobler: It's a very simple process. If someone has an XML file and they give me the URL for it, then I can download the content. There's almost no programming involved. Someone can upload a text file that's basically XML, and I can download it through the browser. It's a little more complicated than that, but not much.

SOAP is also rather slow compared to REST, because of the communication that's going on. When you're using REST, you're pulling that info just as if you were looking at a Web page on the site. It comes down really fast. With SOAP, there's a lot more transactional information moving behind the scenes.





So is REST more of a methodology than a specification?
Hoobler: It's a technique. Other sites that have used this are a lot of the blogger sites, Web log sites and such. They offer the same thing, but they use a method called RSS (Resource Site Summary). They offer almost the exact same thing but it's in RDF (Resource Developer Framework), which is an XML format. For instance, if I have a list of the links on my Web site to tell you about, all I have to do is give you a URL were you can download the info in RDF. So it's similar to REST and what Amazon's doing. It's like a very cheap subscription service. You wouldn't have to write a Web service. You can just go there and get the content.

Amazon.com is currently using a REST-style Web service to share product-pricing info with its reseller partners. What would it have to do if it used SOAP to do the same thing?
Hoobler: First, (Amazon.com) would have to implement a SOAP server. They'd have to build that themselves, which can be complicated, or they could use a third party system. Once they have a SOAP server, end-users would have to build SOAP clients that can communicate with the SOAP server. There would be a lot of programming involved, and most people haven't used SOAP yet, so they'd be left out. With technologies like REST or RSS, that kind of programming doesn't have to take place, and Web services don't take as much effort.


If it's so simple, why hasn't it caught on like SOAP has?
Hoobler: It's not as powerful. With REST, you're just grabbing content. There's not as much processing that needs to be done. You can do much more complex operations with SOAP. If Amazon needed to send me much more information, and then I wanted to process that info -- like in some bank transaction where I had to give them a lot of info -- and then they had to check it and continue the transaction a little bit longer, that's where SOAP is very good. REST has not taken off in the business world because [the] people actually building these big integration servers [think] it's not powerful enough and doesn?t do enough.


Can you give me an example?
Hoobler: If I'm using REST, I might be able to get a Web site's list of stock tickers, but I can't get the values of those tickers. If I'm using SOAP, I can get to the values, manipulate them, and then send the results of my calculations. Let's say I got the values from you, and I wanted to let you know that they're wrong. If I wanted to send you back something that says they're wrong, with REST that can't be done. With REST, you request information, you get it, and that's where it ends.


How easy or difficult is it to learn to work with REST, versus working with SOAP?
Hoobler: To work with SOAP, you really need some kind of infrastructure -- like from IBM or Microsoft -- that supports SOAP. Some third parties, like Cape Clear, offer SOAP implementations, but you have to have all that software installed and know that infrastructure. With REST, to display that information on a Web page, you have to know XML and XSLT, and a lot of platforms -- like WebSphere and all of those Java application servers -- have that built in, or it's very easy to add it on.

Going the other way, if you wanted to use SOAP, you'd have to use the whole .NET framework, or you'd have to use WebSphere Studio. You'd have to use a hefty application, so it's an investment of time and money.


How can a company determine if it should be working with REST instead of SOAP?
Hoobler: I would say if a company's just working with content-oriented data, and you have not implemented SOAP, then REST is a very good way to start working with XML and start displaying syndicated content. If you've implemented SOAP and the infrastructure is in place and you've got programmers coming out your ears, then you don't need to use REST.
文章引用自:http://blog.sina.com.cn/u/467cbd19010002vp
分享到:
评论

相关推荐

    rest转换

    REST(Representational State Transfer,表述性状态转移)是一种软件架构风格,用于设计网络应用程序,尤其在Web服务领域广泛应用。REST转换通常是指将数据或服务接口从其他形式转换为RESTful API的过程。在这个...

    关于rest接口demo的详解

    关于 REST 接口 Demo 的详解 本节主要介绍了 MetaOne 平台 Webservice 接口第 I 条元数据服务接口规范要求元数据管理模块需要采用数据封装的机制对外提供一系列查询和操作的服务接口,将元数据信息和操作封装为标准...

    kettle rest 接口 请求实例

    在Kettle中,REST接口提供了一种灵活的方式与外部系统进行通信,例如,发送和接收JSON数据,执行各种操作。本教程将深入探讨如何使用Kettle与RESTful服务进行交互。 首先,我们要理解REST(Representational State ...

    白话REST-识别真假REST

    REST(Representational State Transfer),即“表征状态转移”,是由Roy Fielding博士在其2000年的博士论文中提出的一种软件架构风格。REST强调基于网络的分布式系统的松耦合设计,并推崇无状态通信机制。在理解...

    nodejs+websock+rest+rest调用

    之前考虑使用socket.io,客户端选择了java swing,很多问题,换了qt写client,连接不上socket.io,很是麻烦,所以转成了现在的模式,js+qt。框架可能对某些人来说没什么,但是这点代码自己折腾了挺长时间,所以分值...

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

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

    Androidannotation使用之@Rest与服务器交互的JSON数据转换

    本文将深入探讨`@Rest`注解以及如何利用它来实现服务器间的JSON数据转换。 首先,`@Rest`注解是AndroidAnnotation库的一部分,这个库是基于Java注解的框架,它能自动处理许多常见的Android任务,如Activity的生命...

    REST Server in Delphi XE Using DataSnap中文版

    ### REST Server 在 Delphi XE 中使用 DataSnap 的关键技术点 #### 1. REST 架构简介 - **背景**: REST(Representational State Transfer)是 Web 服务领域的一个重要概念,尤其在过去十年中,随着 Web 2.0 的...

    Django-REST-framework教程中文版

    Django-REST-framework教程中文版是一份关于如何使用Django-REST-framework来快速创建REST风格API的中文教程。Django-REST-framework是一个建立在Django框架之上的强大的REST API工具包,它允许开发者利用Django的...

    SOAP to REST_library_

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

    REST WebService简单应用

    3. 状态码(Status Codes):HTTP响应状态码提供了关于请求结果的信息,如200表示成功,404表示资源未找到,500表示服务器内部错误等。 4. 数据交换格式(Data Formats):REST服务通常使用JSON(JavaScript Object...

    REST服务示例入门

    本代码源自转自【http://www.lifeba.org/arch/restlet_develop_application_component_2.html 】但有改动,主要改动有: 1. 修改了web.xml的段,使工程既可以访问rest服务,又可以访问普通的页面资源,不用再像原...

    arcgis server rest api

    《ArcGIS Server REST API离线文档详解》 ArcGIS Server REST API是Esri公司提供的一种用于与ArcGIS Server交互的接口,它允许开发者通过HTTP/HTTPS协议访问和操作地理服务,进行地图数据的读取、写入以及处理。这...

    开发rest的简单例子

    在这个“开发REST的简单例子”中,我们将探讨如何使用Spring框架来创建一个RESTful API。 首先,让我们了解REST的基本原则: 1. 客户端-服务器架构:客户端和服务器之间有明确的职责划分,客户端负责用户界面和用户...

    graphqlrestproxy用于将RESTAPI转换为GraphQL

    GraphQL是一种强大的查询语言,它允许客户端定义他们需要的数据,并且只获取那些数据,这与传统的REST API有很大不同。REST API通常需要多个请求来获取相关的数据,而GraphQL通过一个请求就能解决这个问题。`graphql...

    rest的所有jar

    REST(Representational State Transfer,表述性状态转移)是一种软件架构风格,主要用于Web服务的设计和开发,以实现简单、高效和可扩展的交互。RESTful接口是基于HTTP协议,利用HTTP方法(GET、POST、PUT、DELETE...

    Jersey关于搭建Rest服务的案例

    【标题】:Jersey关于搭建REST服务的案例 在当今的Web开发中,RESTful API已经成为构建可伸缩、高效且易于使用的Web服务的标准。Jersey是Java平台上的一个开源库,专门用于实现 Representational State Transfer ...

    Rest所需jar文件

    REST(Representational State Transfer,表述性状态转移)是一种软件架构风格,主要用于Web服务设计,它强调简洁、无状态和基于标准的接口。本压缩包包含了构建REST风格Web架构所需的jar文件,这些文件是开发...

    REST框架简单实现

    REST(Representational State Transfer,表述性状态转移)是一种软件架构风格,主要应用于Web服务的设计,以简洁、无状态和基于标准的方式提供接口。REST框架的实现通常涉及到HTTP协议中的四个基本操作:GET、POST...

Global site tag (gtag.js) - Google Analytics