JSON、REST、SOAP、WSDL 和 SOA:它们如何链接在一起

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16626021/
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-03 19:47:28  来源:igfitidea点击:

JSON, REST, SOAP, WSDL, and SOA: How do they all link together

jsonrestsoapwsdlsoa

提问by Jay

Currently doing some exams and I'm struggling through some concepts. These have all been 'mentioned' in my notes really but I didn't really understand how they all linked together. As far as my understanding is:

目前正在做一些考试,我正在努力解决一些概念。这些都在我的笔记中真的被“提到”过,但我并没有真正理解它们是如何联系在一起的。就我的理解是:

SOA - a solution to make service consumers/providers communicate. (as far as I understand this is the umbrella term for everything else)

SOA - 使服务消费者/提供者进行通信的解决方案。(据我所知,这是其他一切的总称)

WSDL - A language that describes the provider service.

WSDL - 一种描述提供者服务的语言。

SOAP - A XML protocol 'wrapper' used by the services to send messages. Works in conjunction with WSDL as to provide parameters?

SOAP - 服务用于发送消息的 XML 协议“包装器”。与 WSDL 一起工作以提供参数吗?

REST - A design pattern that is similar to SOAP in function but avoids the XML? (really not sure about this one)

REST - 一种在功能上类似于 SOAP 但避免使用 XML 的设计模式?(真的不确定这个)

JSON - An alternative to XML that uses javascript? (not sure about this one either)

JSON - 使用 javascript 的 XML 的替代方案?(也不确定这个)

Looking around in the internet there doesn't seem to be a clear definition of what all of these are and how they interlink.

在互联网上环顾四周,似乎没有明确定义所有这些是什么以及它们如何相互关联。

回答by Anirudh Ramanathan

Imagine you are developing a web-application and you decide to decouple the functionality from the presentation of the application, because it affords greater freedom.

想象一下,您正在开发一个 Web 应用程序,并且您决定将功能与应用程序的呈现分离,因为它提供了更大的自由度。

You create an API and let others implement their own front-ends over it as well. What you just did here is implement an SOAmethodology, i.e. using web-services.

您创建一个 API,并让其他人也通过它实现自己的前端。您在此处所做的是实施SOA方法,即使用 Web 服务。

Web services make functional building-blocks accessible over standard Internet protocols independent of platforms and programming languages.

Web 服务使功能构建块可以通过独立于平台和编程语言的标准 Internet 协议进行访问。

So, you design an interchange mechanism between the back-end (web-service) that does the processing and generation of something useful, and the front-end (which consumes the data), which could be anything. (A web, mobile, or desktop application, or another web-service). The only limitation here is that the front-end and back-end must "speak" the same "language".

因此,您在处理和生成有用的东西的后端(Web 服务)和前端(消费数据)之间设计了一种交换机制,前端可以是任何东西。(网络、移动或桌面应用程序,或其他网络服务)。这里唯一的限制是前端和后端必须“说”同一种“语言”。



That's where SOAP and REST come in. They are standard ways you'd pick communicate with the web-service.

这就是 SOAP 和 REST 的用武之地。它们是您选择与 Web 服务进行通信的标准方式。

SOAP:

肥皂:

SOAPinternally uses XML to send data back and forth. SOAP messages have rigid structure and the response XML then needs to be parsed. WSDLis a specification of what requests can be made, with which parameters, and what they will return. It is a complete specification of your API.

SOAP 在内部使用 XML 来回发送数据。SOAP 消息具有严格的结构,然后需要解析响应 XML。 WSDL是关于可以发出什么请求、使用什么参数以及它们将返回什么的规范。它是您的 API 的完整规范。

REST:

休息:

REST is a design concept.

REST 是一种设计理念。

The World Wide Web represents the largest implementation of a system conforming to the REST architectural style.

万维网代表了符合 REST 架构风格的系统的最大实现。

It isn't as rigid as SOAP. RESTful web-servicesuse standard URIs and methods to make calls to the webservice. When you request a URI, it returns the representationof an object, that you can then perform operations upon (e.g. GET, PUT, POST, DELETE). You are not limited to picking XML to represent data, you could pick anything really (JSON included)

它不像 SOAP 那样僵化。RESTful Web 服务使用标准 URI 和方法来调用 Web 服务。当您请求一个 URI 时,它返回一个对象的表示,然后您可以对其执行操作(例如 GET、PUT、POST、DELETE)。您不仅可以选择 XML 来表示数据,您还可以选择任何真正的东西(包括 JSON)

Flickr's REST API goes further and lets you return images as well.

Flickr 的 REST API 走得更远,还允许您返回图像。



JSONand XML, are functionally equivalent, and common choices. There are also RPC-based frameworks like GRPC based on Protobufs, and Apache Thrift that can be used for communication between the API producers and consumers. The most common format used by web APIs is JSON because of it is easy to use and parse in every language.

JSONXML在功能上是等效的,并且是常见的选择。还有基于 RPC 的框架,如基于 Protobufs 的 GRPC 和 Apache Thrift,可用于 API 生产者和消费者之间的通信。Web API 最常用的格式是 JSON,因为它易于在每种语言中使用和解析。

回答by Saman Gholami

WSDL: Stands for Web Service Description Language

WSDL:代表 Web 服务描述语言

In SOAP(simple object access protocol), when you use web service and add a web service to your project, your client application(s) doesn't know about web service Functions. Nowadays it's somehow old-fashion and for each kind of different client you have to implement different WSDLfiles. For example you cannot use same file for .Netand phpclient. The WSDLfile has some descriptions about web service functions. The type of this file is XML. SOAPis an alternative for REST.

在 SOAP(简单对象访问协议)中,当您使用 Web 服务并将 Web 服务添加到您的项目时,您的客户端应用程序不知道 Web 服务功能。如今,它在某种程度上已经过时了,对于每种不同的客户端,您都必须实现不同的WSDL文件。例如,您不能为.Netphp客户端使用相同的文件。该WSDL文件有一些关于 Web 服务功能的描述。此文件的类型是XML. SOAP是 的替代方案REST

REST: Stands for Representational State Transfer

REST:代表表征状态转移

It is another kind of API service, it is really easy to use for clients. They do not need to have special file extension like WSDLfiles. The CRUD operation can be implemented by different HTTP Verbs(GET for Reading, POST for Creation, PUT or PATCH for Updating and DELETE for Deleting the desired document) , They are based on HTMLprotocol and most of times the response is in JSONor XMLformat. On the other hand the client application have to exactly call the related HTTP Verbvia exact parameters names and types. Due to not having special file for definition, like WSDL, it is a manually job using the endpoint. But it is not a big deal because now we have a lot of plugins for different IDEs to generating the client-side implementation.

它是另一种 API 服务,对于客户端来说真的很容易使用。它们不需要像WSDL文件那样具有特殊的文件扩展名。CRUD 操作可以通过不同的方式实现HTTP Verbs(GET 用于读取,POST 用于创建,PUT 或 PATCH 用于更新和 DELETE 用于删除所需的文档),它们基于HTML协议,并且大多数情况下响应采用JSONXML格式。另一方面,客户端应用程序必须HTTP Verb通过精确的参数名称和类型精确调用相关的。由于没有用于定义的特殊文件,例如WSDL,它是使用端点的手动作业。但这没什么大不了的,因为现在我们有很多插件可以用于不同的 IDE 来生成客户端实现。

SOA: Stands for Service Oriented Architecture

SOA:代表面向服务的架构

Includes all of the programming with web services concepts and architecture. Imagine that you want to implement a large-scale application. One practice can be having some different services, called micro-services and the whole application mechanism would be calling needed web service at the right time. Both RESTand SOAPweb services are kind of SOA.

包括所有具有 Web 服务概念和体系结构的编程。想象一下,您要实现一个大型应用程序。一种做法是拥有一些不同的服务,称为微服务,整个应用程序机制将在正确的时间调用所需的 Web 服务。这两个RESTSOAPWeb服务是一种SOA

JSON: Stands for javascript Object Notation

JSON: 代表javascript Object Notation

when you serialize an object for javascript the type of object format is JSON. imagine that you have the human class :

当您为 javascript 序列化对象时,对象格式的类型是 JSON。想象一下,你有人类类:

class Human{
 string Name;
 string Family;
 int Age;
}

and you have some instances from this class :

你有这个类的一些实例:

Human h1 = new Human(){
  Name='Saman',
  Family='Gholami',
  Age=26
}

when you serialize the h1 object to JSON the result is :

当您将 h1 对象序列化为 JSON 时,结果是:

  [h1:{Name:'saman',Family:'Gholami',Age:'26'}, ...]

javascriptcan evaluate this format by eval()function and make an associative array from this JSONstring. This one is different concept in comparison to other concepts I described formerly.

javascript可以通过eval()函数评估此格式并从此JSON字符串创建关联数组。与我之前描述的其他概念相比,这是一个不同的概念。