Web 服务是 SOAP 还是 REST? [英] SOAP or REST for Web Services?

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

问题描述

REST 是一种更好的 Web 服务方法还是 SOAP?或者它们是针对不同问题的不同工具?或者这是一个微妙的问题 - 也就是说,某个领域在某些领域是否比其他领域略好等?

Is REST a better approach to doing Web Services or is SOAP? Or are they different tools for different problems? Or is it a nuanced issue - that is, is one slightly better in certain arenas than another, etc?

我特别感谢有关这些概念及其与 PHP 世界以及现代高端 Web 应用程序的关系的信息.

I would especially appreciate information about those concepts and their relation to the PHP-universe and also modern high-end web-applications.

推荐答案

当我在 Hewlett 工作时,我根据正在开发的原始规范构建了第一个 SOAP 服务器,包括代码生成和 WSDL 生成 -帕卡德.我不建议将 SOAP 用于任何事情.

I built one of the first SOAP servers, including code generation and WSDL generation, from the original spec as it was being developed, when I was working at Hewlett-Packard. I do NOT recommend using SOAP for anything.

首字母缩略词SOAP"是一个谎言.它不是简单的,不是面向对象的,它没有定义访问规则.可以说,它是一个协议.这是 Don Box 有史以来最糟糕的规格,这是一项了不起的壮举,因为他是犯下COM"的人.

The acronym "SOAP" is a lie. It is not Simple, it is not Object-oriented, it defines no Access rules. It is, arguably, a Protocol. It is Don Box's worst spec ever, and that's quite a feat, as he's the man who perpetrated "COM".

在 SOAP 中,没有什么东西是用 REST 传输、JSON、XML 甚至纯文本来表示数据无法完成的.为了传输安全,您可以使用 https.对于身份验证,基本身份验证.对于会话,有 cookie.REST 版本将更简单、更清晰、运行速度更快并且使用更少的带宽.

There is nothing useful in SOAP that can't be done with REST for transport, and JSON, XML, or even plain text for data representation. For transport security, you can use https. For authentication, basic auth. For sessions, there's cookies. The REST version will be simpler, clearer, run faster, and use less bandwidth.

XML-RPC 明确定义了请求、响应和错误协议,并且对于大多数语言都有很好的库.但是,对于许多任务,XML 比您需要的要繁重.

XML-RPC clearly defines the request, response, and error protocols, and there are good libraries for most languages. However, XML is heavier than you need for many tasks.

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

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