XML 和 SOAP 之间的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2426096/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 13:01:28  来源:igfitidea点击:

Difference between XML and SOAP

xmlsoap

提问by Richard Knop

What is the difference between XML and SOAP? I've been reading some introductory articles about SOAP but I am very confused. This is the first time I am reading about SOAP so maybe that's natural.

XML 和 SOAP 之间有什么区别?我一直在阅读一些关于 SOAP 的介绍性文章,但我很困惑。这是我第一次阅读有关 SOAP 的信息,所以这可能很自然。

Could somebody please explain to me what SOAP is and what it is used for? Maybe give me some examples of its usage?

有人可以向我解释什么是 SOAP 以及它的用途吗?也许给我一些它的用法的例子?

采纳答案by Derek Adair

Wikipedia has a wonderful article, including a good example.

维基百科有一篇精彩的文章,包括一个很好的例子

SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks.

SOAP,最初定义为简单对象访问协议,是一种用于在计算机网络中实现 Web 服务时交换结构化信息的协议规范。

A really good practical example:

一个非常好的实际例子:

As a layman's example of how SOAP procedures can be used, a SOAP message could be sent to a web-service-enabled web site (for example, a house price database) with the parameters needed for a search. The site would then return an XML-formatted document with the resulting data (prices, location, features, etc). Because the data is returned in a standardized machine-parseable format, it could then be integrated directly into a third-party site.

作为如何使用 SOAP 过程的外行示例,可以将 SOAP 消息与搜索所需的参数一起发送到支持 Web 服务的网站(例如,房价数据库)。然后该站点将返回一个带有结果数据(价格、位置、功能等)的 XML 格式的文档。由于数据以标准化的机器可解析格式返回,因此可以直接集成到第三方站点中。

回答by Marvin Smit

After reading all of the other good answers, I thought it might be helpful to provide a "super laymans" version. I hope it helps.

在阅读了所有其他好的答案后,我认为提供“超级外行”版本可能会有所帮助。我希望它有帮助。



SOAP is like the computer version using the postal service. A message (like a letter) is placed in an envelope and sent off to the person it is intended for.

SOAP 就像使用邮政服务的计算机版本。一条信息(如一封信)被放在一个信封里,然后寄给它的目标人。

Primarily, SOAP is an XML vocabulary. It defines a language, using the XML specification, for how to address and send send messages.

首先,SOAP 是一个 XML 词汇表。它使用 XML 规范定义了一种语言,用于处理和发送发送消息。

Specifically, it standardizes what we refer to as:

具体来说,它标准化了我们所说的:

  • "an envelope" (actually called a SOAP envelope)
  • "the letter" (called "the body")
  • various annotations (called "headers" - think of these like stamps, signature request, sender information, etc - which the post-office uses to route the message)
  • “一个信封”(实际上称为 SOAP 信封)
  • “信”(称为“正文”)
  • 各种注释(称为“标题” - 想想这些,如邮票、签名请求、发件人信息等 - 邮局用来路由消息)

In addition, SOAP defines a type-system, much like the type definitions you find in .Net, Java or XSD. I won't elaborate on this - as there is plenty of documentation out there as mentioned in previous answers.

此外,SOAP 定义了type-system,很像您在 .Net、Java 或 XSD 中找到的类型定义。我不会详细说明这一点 - 因为前面的答案中提到了很多文档。

The primary design focus of this language/vocabulary was to allow interoperability across platforms. So, Java calling COM, calling .Net, calling J2EE and the rest while remaining extendable for the foreseeable future. Instead of building yet another bridge between a COM object and a Java class, we can simply use SOAP to expose the functionality of our object so that other platforms can use them without the need for bridges. Or, to put it differently - SOAP was one last bridge, designed to replace all of the previous bridges.

这种语言/词汇的主要设计重点是允许跨平台的互操作性。因此,Java 调用 COM、调用 .Net、调用 J2EE 等,同时在可预见的未来保持可扩展性。无需在 COM 对象和 Java 类之间建立另一个桥梁,我们可以简单地使用 SOAP 来公开我们对象的功能,以便其他平台可以在不需要桥梁的情况下使用它们。或者,换一种说法 - SOAP 是最后一座桥,旨在取代所有以前的桥。

By now, all major development toolkits have some form of SOAP support. This has made interoperability more and more available - but in most environments, a certain level of configuration is still necessary in order to make communication truly seamless.

到现在为止,所有主要的开发工具包都具有某种形式的 SOAP 支持。这使得互操作性越来越可用 - 但在大多数环境中,为了使通信真正无缝,仍然需要一定级别的配置。

I should note also that SOAP no longer stands for what its original intent was. At some point, I think some important person will (re)name it: Service Oriented Access Protocol.

我还应该注意到 SOAP 不再代表它的原始意图。在某些时候,我认为某个重要人物会(重新)命名它:Service Oriented Access Protocol.

I hope this helps!

我希望这有帮助!

回答by crowne

SOAP is a messaging protocol used over networks to invoke web-services.
The message formats use XML, and are described by WSDL's - pronounced wizdil.

SOAP 是一种用于通过网络调用web-services的消息传递协议。
消息格式使用 XML,并由WSDL描述- 发音为 wizdil。

WSDL's are also XML documents.

WSDL 也是 XML 文档。

XML is a document format that uses tags to identify the contents of the file, its usage is wider than SOAP and WSDL which are specific types of XML.
See the w3schools tutorial for XML at http://www.w3schools.com/xml/default.asp

XML 是一种使用标签来标识文件内容的文档格式,其用途比 SOAP 和 WSDL 是特定类型的 XML。
请参阅http://www.w3schools.com/xml/default.asp 上的 w3schools XML 教程