RESTful与基于SOAP的Web服务? [英] RESTful vs SOAP based webservices?

查看:165
本文介绍了RESTful与基于SOAP的Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近通过webservices一书,其中介绍了基于SOAP的Web服务和RESTful Web服务。
我不确定我应该选择其中一个参数,因为它们看起来都很相似(甚至从开发人员的角度来看)。以下是我的观点

Folks I recently went thru webservices book which covered SOAP based webservices and RESTful webservices. I am not sure on what parameters I should select one of them as both of them looks similar(even from developer perspective). Here are my points

在SOAP webservices中,我们使用从webservices生成的WSDL文件,然后基于此创建客户端存根。

In SOAP webservices we use WSDL file generated out of webservices and then create client side stubs based on that.


我的理解是内部存根也将使用HTTP协议
与远程java webservice进行通信。对吗?

My understanding is that internally stub also will use HTTP protocol to communicate with remote java webservice. Right?

这里HTTP请求/响应主体内部将有SOAP消息(XML消息)。因此,在基于REST的Web服务中,还有一层要向下钻取,HTTP请求本身就像消息一样。这里我们有WADL而不是WSDL。在这里我们也可以基于WADL创建存根。因此,除了一些技术差异之外,每件事看起来或多或少都相同。消费者连接到生产者以及如何处理请求/响应。据我所知,基于b / w rest和开发人员的基于SOAP的webservices没有太大区别观点(开发人员的工作量几乎相同)。

Here there will be SOAP message(XML message) inside HTTP request/response body. so one more layer to drill down while in REST based webservices, HTTP request itself behave as messages. Here we have WADL instead of WSDL. Here also we can create the stubs based on WADL. So every things looks more or less same except the some technical difference consumer connect to producer and how request/reponse are processed.So as per my understanding there is not much difference b/w rest based and soap based webservices from developer point of view (amount of work for developer is almost same).

我的理解是否正确?

是可能在幕后,SOAP可能比SOAP中的REST webservices becoz更复杂,消息内部有消息(SOAP消息嵌入在HTTP请求中),但在基于REST的服务中,HTTP请求本身就是消息。

Yes probably behind the scenes, probably SOAP is more complicated than REST webservices becoz in SOAP, there is messages inside message(SOAP message is embedded inside HTTP request) but in REST based services, HTTP request itself works as message.

推荐答案

SOAP和REST旨在解决一组相同的问题,即以最简单的方式促进异构应用程序之间的交互。现在,是否选择REST或SOAP并不仅仅取决于开发工作量。您还应该考虑以下一些因素:

SOAP and REST are aimed at solving a identical set of problems, namely facilitate the interaction between heterogeneous applications in easiest possible manner. Now whether to choose REST or SOAP does not just depend on the amount of development effort. You should consider some of following factors as well,


  1. 数据类型是否只是简单的对象(如名称值对)或在应用程序之间交换的非常复杂的模式(或一些二进制数据)。

  2. 您服务的消费者。例如。在开发 RIA 时,REST更适合。

  3. 安全要求。 SOAP凭借标准驱动,提供了非常精细的安全方面的粒度调整。您可以对SOAP xml消息的各个元素进行编码。这些类型的东西在REST中是不可能的(至少目前为止)。

  4. 现在,像 JSON 这样的符号在轻量级数据交换和许多REST服务框架中非常流行提供这个非常容易开箱即用。

  5. 从技术上讲,您不需要任何框架等来创建REST Web服务。我知道WADL等最近引入了一个标准化元素,但是在WADL出现之前,REST仍然存在。 REST并不是什么新鲜事,它的网络运作方式。 REST框架使它变得非常简单。

  1. The type of data whether its just simple objects (like name value pair) or very complex schema (or some binary data) to be exchanged between the applications.
  2. The consumer of your service. E.g. REST are more suitable when you are developing RIA.
  3. Security requirement. SOAP by virtue of being standard driven, offers a very fine grain level tuning of security aspect. You can go to an extent of encoding the individual elements of your SOAP xml message. These type of things are not possible in REST (at lest for now).
  4. Nowadays notations like JSON are quite popular for lightweight data exchange and many REST service frameworks offers this very easily out of box.
  5. Technically, you do not need any framework etc to create a REST web service. I understand that WADL etc came recently to bring in an element of standardization but REST existed even before WADL came. REST is nothing new, its the way web works. REST frameworks make it very easy.

SOAP由标准驱动,因此在使用它们时会有更多的限制。因此,如果您使用案例很简单(那是非常主观的),请选择REST。

SOAP is driven by standards and hence there are more constraints to honor when you work with them. So if you use case is simple (well that's very subjective), go for REST.

这篇关于RESTful与基于SOAP的Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆