Web服务类型:SOAP和REST

There are two types of web services:

Web服务有两种类型:

  1. SOAP Web Services

    SOAP Web服务

  2. REST Web Services

    REST Web服务

SOAP Web服务 (SOAP Web Services)

SOAP is an XML-based protocol. The biggest advantage of using the SOAP Web Service is its own security. SOAP stands for Simple Object Access Protocol.

SOAP是基于XML的协议。 使用SOAP Web服务的最大优势是其自身的安全性。 SOAP代表简单对象访问协议

SOAP provides an envelope to send a web services messages over the Internet, using the HTTP protocol. The messages are generally in XML format.

SOAP提供了一个信封,用于使用HTTP协议通过Internet发送Web服务消息。 消息通常为XML格式。

SOAP request envelope

In simple words, SOAP is a technique to send an XML request over the Internet using HTTP protocol (hitting a URL), and in return getting an XML response.

简而言之,SOAP是一种使用HTTP协议(点击URL)在Internet上发送XML请求并获得XML响应的技术。

Taking a real world example, if a client wants to fetch a school's student data, by sending in the student's Roll No. in the request, he can do so using web services. But how will the client know, which URL to call and what to send in the request?

以真实世界为例,如果客户想要获取学校的学生数据,则可以通过在请求中发送学生的卷号来获取学校的学生数据,他可以使用Web服务来这样做。 但是客户端将如何知道,调用哪个URL以及在请求中发送什么?

SOAP communication real life example

Well, every application serving SOAP requests, has a WSDL file. WSDL is an XML, and it stands for Web Service Description Language. WSDL describes all the methods available in the web service, along with the request and response types. It describes the contract between service and client.

嗯,每个服务SOAP请求的应用程序都有一个WSDL文件 。 WSDL是XML,代表Web服务描述语言。 WSDL描述了Web服务中可用的所有方法以及请求和响应类型。 它描述了服务与客户之间的合同。

SOAP was intended to be a way to do remote procedure calls to remote objects by sending XML over HTTP.

SOAP旨在成为一种通过HTTP发送XML来对远程对象进行远程过程调用的方法。

If we look at the current software industry, you will find that, SOAP is being used in the enterprise applications, generally in the legacy code. Today the world is moving fast towards the RESTful Web Services.

如果我们看一下当前的软件行业,您会发现,SOAP已在企业应用程序中使用,通常在遗留代码中使用。 今天,世界正朝着RESTful Web服务迈进。

REST Web服务 (REST Web Services)

The REST stands for Representational State Transfer. REST is not a set of standards or rules, rather it is a style of software architecture. The applications which follow this architecture are referred to as RESTful

REST代表代表性状态转移 。 REST不是一组标准或规则,而是一种软件体系结构。 遵循此体系结构的应用程序称为RESTful

Unlike SOAP which targets the actions, REST concerns more on the resources. REST locates the resources by using URL and it depends on the type of transport protocol(with HTTP - GET, POST, PUT, DELETE,...) for the actions to be performed on the resources. The REST service locates the resource based on the URL and performs the action based on the transport action verb. It is more of architectural style and conventions based.

与以动作为目标的SOAP不同,REST更关注资源。 REST通过使用URL来定位资源,并且它取决于要在资源上执行的操作的传输协议的类型(使用HTTP-GET,POST,PUT,DELETE等)。 REST服务根据URL定位资源,并根据传输动作动词执行动作。 它更多地基于建筑风格和惯例。

For Example: in a RESTful architecture, this URL http://{serverAddress}/students/studentRollno/07 can be used to:

例如:在RESTful体系结构中,此URL http:// {serverAddress} / students / studentRollno / 07可用于:

  • To get student information by sending a REST call of GET type, and the service will return information of student with roll no as 07

    通过发送GET类型的REST调用获取学生信息,服务将返回卷号为07的学生信息

  • The same service can also be used to update the student data, by sending in the new values as Form data in a PUT request.

    通过将新值作为PUT请求中的表单数据发送出去,该服务也可以用于更新学生数据。

REST architecture example

REST和SOAP之间的区别 (Difference between REST and SOAP)

Here are some of the basic differences between the two types of web services:

这是两种类型的Web服务之间的一些基本区别:

RESTSOAP
REST is a style of software architecture.SOAP is a protocol or a set of standards.
REST stands for Representational State TransferSOAP stands for Simple Object Access Protocol
REST can use SOAP because it is a concept and can use any protocol like HTTP, SOAP etc.SOAP cannot use REST because it itself is a protocol.
REST uses URI to expose business logic. But as REST works on the basis of type of HTTP request, hence same URI can work for more than a single type of operation.SOAP uses the service interface to expose business logic.
REST does not define too much standards. REST is cool!SOAP defines standards to be strictly followed.
REST inherits security measures from the underlying transport protocols.SOAP defines its own security layer.
REST accepts different data formats like, Plain Text, HTML, JSON, XML etc.SOAP only works with XML format.
休息 肥皂
REST是一种软件体系结构。 SOAP是一个协议或一组标准。
REST代表代表性状态转移 SOAP代表简单对象访问协议
REST可以使用SOAP,因为它是一个概念,可以使用任何协议,例如HTTP,SOAP等。 SOAP无法使用REST,因为它本身是协议。
REST使用URI公开业务逻辑。 但是由于REST基于HTTP请求的类型工作,因此相同的URI不仅可以用于单一类型的操作。 SOAP使用服务接口公开业务逻辑。
REST没有定义太多标准。 REST很酷! SOAP定义了严格遵循的标准。
REST从基础传输协议继承安全措施。 SOAP定义了自己的安全层。
REST接受不同的数据格式,例如纯文本,HTML,JSON,XML等。 SOAP仅适用于XML格式。

翻译自: https://www.studytonight.com/rest-web-service/types-of-webservices

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值