为什么要使用 REST 而不是基于 SOAP 的服务? [英] Why would one use REST instead of SOAP based services?

查看:32
本文介绍了为什么要使用 REST 而不是基于 SOAP 的服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天参加了一个有趣的 REST 演示,但是,我想不出一个原因(也没有提出)为什么 REST 比基于 SOAP 的服务堆栈更好或更易于使用和实现.

Attended an interesting demo on REST today, however, I couldn't think of a single reason (nor was one presented) why REST is in anyway better or simpler to use and implement than a SOAP based Services stack.

为什么现实世界"中有人使用 REST 而不是基于 SOAP 的服务的一些原因是什么?

What are some of the reasons Why anyone in the "real world" use REST instead of the SOAP based Services?

推荐答案

更少的开销(没有 SOAP 信封来包装每个调用)

Less overhead (no SOAP envelope to wrap every call in)

减少重复(HTTP 已经表示 DELETE、PUT、GET 等操作,否则这些操作必须在 SOAP 信封中表示).

Less duplication (HTTP already represents operations like DELETE, PUT, GET, etc. that have to otherwise be represented in a SOAP envelope).

更标准化 - HTTP 操作被很好地理解并且操作一致.一些 SOAP 实现可能会很挑剔.

More standardized - HTTP operations are well understood and operate consistently. Some SOAP implementations can get finicky.

更具人类可读性和可测试性(仅使用浏览器更难测试 SOAP).

More human readable and testable (harder to test SOAP with just a browser).

不需要使用 XML(好吧,您也不必为 SOAP 使用 XML,但这几乎没有意义,因为您已经在解析信封了).

Don't need to use XML (well you kind of don't have to for SOAP either but it hardly makes sense since you're already doing parsing of the envelope).

库使 SOAP(有点)变得简单.但是正如我所指出的那样,您正在抽象出很多下面的冗余.是的,理论上 SOAP 可以通过其他传输,以避免在一层之上做类似的事情,但实际上,您所做的几乎所有 SOAP 工作都是通过 HTTP 进行的.

Libraries have made SOAP (kind of) easy. But you are abstracting away a lot of redundancy underneath as I have noted. yes in theory SOAP can go over other transports so as to avoid riding atop a layer doing similar things, but in reality just about all SOAP work you'll ever do is over HTTP.

这篇关于为什么要使用 REST 而不是基于 SOAP 的服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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