普通网络服务和基于肥皂的网络服务有什么区别?
据我所知,有两种类型的网络服务。第一个是自定义 xml 格式的消息,第二个是 SOAP 标准 xml 消息。它们之间有什么区别?哪一种更好,这两种方法各自的优缺点是什么?
There are 2 types of web-services as I know. First one is custom xml formatted messages and the second one SOAP standard xml messages. What are the differences between them? Which one is better, what are pros and cons of each of that two approaches?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为“普通”是指 RESTful 服务。这次讨论会很长,因此我将尝试向您提供一些要点:
RESTful 服务是最常用的 Web 服务风格。它们与 HTTP 的功能和原理紧密相连,可以像 GET 请求一样简单地访问(其他操作是 POST、DELETE 和 PUT)。核心概念是由 URI 标识的“资源”。 REST 的常见格式是 XML 和 JSON。这是一种非常简单且易于使用的技术,这也是它如此广泛使用的原因。
SOAP Web 服务基于 XML,其中大多数遵循 RPC 风格的应用程序设计(调用服务器上的远程方法并获取响应),并使用 3 个主要支柱:
SOAP Web 服务往往具有较高的开销,并且通常具有非常详细的消息,但如果您需要在应用程序中实现更复杂的功能和交互,则可能会很好。
By "ordinary" I assume you mean RESTful services. This discussion would be a long one, so I'll try to give you some key points:
RESTful services are the most used flavor of Web Services. They are closely linked to the functionality and principles of HTTP and can be accessed as simple as a GET request (other operations are POST, DELETE and PUT). The core concept is the "resource" which is identified by an URI. Common formats for REST are XML and JSON. It's a pretty straightforward and easy to use technology, which is what makes it so widely available.
SOAP web services are based on XML, most of them adhering to the RPC-style of app design (calling remote methods on a server and getting a response), and use 3 main pillars:
SOAP Web Services tend to have high overhead and generally have very verbose messages, but may be good if you need to implement more complex functionality and interaction in your application.
严格来说,只有 Soap 服务才是 Web 服务。它们基于由 W3C 和 Oasis 标准化的 WS-* 规范。有时,也称为 Web 服务的 POX 端点(普通旧 XML)或 REST 端点,它允许您通过 HTTP GET 简单地获取原始 XML。
SOAP 服务以 wsdl 端点的形式承载其架构(通常将 ?wsdl 附加到服务端点),因此有很多工具可以创建代理对象并隐藏 Web 服务调用的复杂性。使用 POX 服务,您需要从文档等中了解要使用哪个模式。
SOAP 服务在 SOAP 信封(带有标头和主体的 XML 模式,主体中包含有效负载)内携带有效负载。拥有独立于有效负载的标头允许在不知道内容的情况下重新路由内容、签名和加密、身份验证等。但是您需要支付消息本身的额外开销。
另一方面,POX 将所有这些工作交给网络服务器,并且通常依赖 HTTP 进行身份验证和压缩。加密和签名必须由您的系统完成。它的开销很低,但可发现性也很低。
什么最适合您很大程度上取决于您的场景。如果您在 .Net 或 Java 世界中工作,您通常会发现创建代理并使用它作为远程对象来处理 Web 服务是最简单的方法。您将获得良好构建的基础架构和舒适的编程体验。如果您的环境不支持代理生成或者必须从任何东西调用它,POX 可能是更轻量级的方法。
Strictly speaking only the Soap services are webservices. They are based on the WS-* Specs standardisized by W3C and Oasis. Sometimes a also reffered as Webservice are so called POX-Endpoint (Plain old XML) or REST Endpoint, which allows you to simply get a raw XML via HTTP GET.
SOAP Services carry their schema in form of a wsdl endpoint (usualy append ?wsdl to the service endpoint), so there a lots of tools to create proxy objects and hide the complexity of the webservice call. With POX Services you need to know which schema to use from e.g. the documentation.
SOAP Services carry the payload inside the SOAP Envelope (an XML Schema with header and body with the payload in the body). Having a header independent from the payload allows to reroute the content, sign and encrypt, authenticate etc. without knowing the content. But you pay by additional overhead in the message itself.
POX on the other hand leaves all that to the webserver and relies usualy on HTTP for authentification and compression. Encription and signing had to be done by your system. It is low overhead but also low discoverability.
Whats works best for you depends a lot on your scenario. If you work in a .Net or Java World, you often find it simplest to create a proxy and use that to work with the webservices as remote objects. You get a well build infrastructure and a comfortable programming experience. If youre environment does not support the proxy generation or if it had to be called from anything, POX might the very much more lightweight way to go.
“Web Service”是指一个更抽象、更笼统的概念。可以说,任何可以在 Web 上提供服务的东西都是 Web 服务。 SOAP Web 服务或 RESTful 服务是一种特殊的 Web 服务,具有广泛的接受度并拥有自己的标准。虽然 SOAP 服务是建立在基于 XML 的新标准之上,但 RESTful 方法利用了现有的 HTTP 方法,因此更被广泛接受(根据我的经验)。
"Web Service" refers to a more abstract and general concept. We can say that anything that can be served on web is a Web Service. SOAP Web Services or RESTful services are special kind of Web Services which has wide acceptance and has their own standards. While SOAP services are built on a new XML based standard, RESTful approach makes use of existing HTTP methods, hence more widely accepted (to my experience).