📜  Web 服务和 Web API 之间的差异

📅  最后修改于: 2021-09-12 10:39:42             🧑  作者: Mango

Web 服务: Web 服务是可以通过 Internet 访问并通过 XML 编码规范其对应关系的任何位服务。客户通过发送请求(大部分为 XML 消息)来调用 Web 服务,然后服务发回 XML 响应。 Web 服务通过网络进行通信,HTTP 是两个框架之间最广泛认可的网络方法。 Web 服务相当于 SOA(面向服务的体系结构)并且从根本上依赖于度量,例如 XML-RPC 和 SOAP(简单对象访问协议)。

组件:所有标准 Web 服务都使用以下组件工作。

  • SOAP(简单对象访问协议)
  • UDDI(通用描述、发现和集成)
  • WSDL(Web 服务描述语言)

Web API: API代表应用程序编程接口。它是各种程序用来在它们之间进行通信的通信约定和子程序的集合。开发人员可以利用不同的 API 设备来使其程序更简单和更简单。同样,API 鼓励开发人员以熟练的方法构建他们的产品程序。因此,简单来说,API 决定了编程段应该如何相互关联。它是一组协议和时间表,其反应以数据中的 JSON 或 XML 形式返回。 API 可以使用任何类型的通信约定,并且不像 Web 服务那样受到限制。

Web 服务和 API 之间的区别:

Web Services Web API
Web services are a type of API, which must be accessed through a network connection. APIs are application interfaces, implying that one application can communicate with another application in a standardized manner.
Web service is used for REST, SOAP and XML-RPC for communication. API is used for any style of communication.
All Web services are APIs. APIs are not web services.
It doesn’t have lightweight design, needs a SOAP convention to send or receive data over the system. It has a light-weight architecture furthermore, useful for gadgets which have constrained transmission capacity like smart phones.
It provides supports only for the HTTP protocol. It provides support for the HTTP/s protocol: URL Request/Response Headers, and so on.
It is not open source, however, can be devoured by any customer that comprehends xml. It is an open source and also ships with .NET framework.
Web service supports only XML. API supports XML and JSON.
Web Services can be hosted on IIS. Web API can be hosted only on IIS and self.