前言

分享一篇我在edx课程中看到的一篇英文文章,这篇文章详细阐述了Web、Web Server的含义,然后进一步介绍什么是Web API、Web Server、SOAP以及RESTFUL Web API的一些基础概念。本文根据个人的理解对原文进行了翻译,限于我的知识水平,若有翻译不到位的地方还请批评指正。

正文

Web究竟是什么意思?

如今,网络十分普及。运行在不同电脑上的软件可以互相“对话”。软件们进行交流时所使用的语言称之为“协议”(protocols)。比如你可能听说过的TCP、HTTP以及FTP协议。

Web其实就是在某一网络中的一组计算机,它们通过HTTP协议进行交流。Web可大可小,比如:

  • 在公司的内网中,如果有一些计算机通过HTTP协议交流,借助Web浏览器分享文件,那它们构成的是一个小型网络(SMALL Web)。

  • 在互联网(the Internet)上,数以亿计的电脑和设备通过HTTP协议组成了一个大型网络(BIG Web)。事实上,它是地球上最大的东西之一,即万维网(the Would Wide Web)。

什么是网络服务器(Web Server)?

通常,当软件通过网络进行交流的时候,每个软件程序所扮演的角色可能是不同。如果一个程序持有某些资源,例如数据或者一组逻辑指令,此外,它还能提供这些资源给其他程序,便可将该程序以及运行该程序的电脑称之为服务器(Server),即服务提供者。相反,如果一个程序没有它所需要的资源,不得不向网络中的其他程序请求资源,我们可以将它称之为客户端(Client

当程序通过网络来提供数据或者计算资源(computing power,直译为计算能力,但显得有些生硬,此处我译为计算资源,表示计算机它所能提供的计算能力)的时候,便称之为Web服务器(Web server)。因为在网络上的计算机/设备是通过HTTP协议相连接的,我们可以轻松的推断出:网络服务器必须通过HTTP协议提供或者暴露自身所持有的资源。

网络服务器能够提供给客户端的资源是庞大的,但是总体上我们能分成两类:数据计算资源。服务器上数据的表征形式很多,比如HTML页面、PNG 图像、MP3/MP4文件或者在数据库中的一连串记录。计算资源是指服务器所能提供的计算能力,而服务器的计算性能通常要比客户端强很多,当然这取决于客户计算机上的硬件条件。

通过请求,客户端可以向服务器发送参数,在服务器接受参数并且执行某些计算以后,将通过一个响应(response)返回相应的结果给客户端。

  • 如果网络服务器提供数据资源,并且数据是HTML格式的(我们知道浏览器能够渲染HTML编写的页面),我们称这个网络服务器的资源为站点(Website)。

  • 如果网络服务器提供数据资源,并且数据被序列化成XML、JSON或者其他格式,我们将它称之为数据网络服务(Data Web service)或者数据服务(Data Service)

  • 如果一个网络服务器提供计算资源,这意味着客户端可以远程调用网络服务器上的计算资源,并且网络服务器将以合适的格式返回计算结果,我们称这类网络服务器为网络服务(Web Services)或者网络API(Web API)

正如你所注意到的,无论资源的类型是什么,都必须在给客户端的响应(response)中包含一些结果或者数据。这些结果数据证明了服务器上资源的存在性,我们称这些数据是资源的表征形式(representataion)

什么是Web API?

API表示应用程序接口(Application Programming Interface),它对使用类库中的成员而言是极其重要的。如果你想成功地使用类库中的成员,你必须遵守由这些类库开发者定义的API。

在引用类库以后,应用程序能够轻易地在单个计算机中调用或使用类库中的功能。实际的问题是应用程序和类库不在同一电脑上。那我们怎样才能在客户端的电脑上调用另一台电脑上的API呢?

对于这个问题有很多解决方案,例如远程过程调用(RPC, Remote Procedure Call)、公共对象请求代理体系结构(CORBA,Common Object Request Broker Architecture)等等。最终,开发者将远程调用嫁接到网络服务器上。这导致类库寄宿在网络服务器上并且通过HTTP协议暴露类库中的接口。

通过这种方式网络服务器可以集中计算资源并将它发布成网络服务(Web Services),客户端就可以远程使用服务器上的计算资源了。因为客户端仍然在调用类库中的API,只不过是通过网络(the web)远程地使用,我们称这种类型的网络服务为Web API。简而言之,如果一个网络服务作为一个类库的外包装,将其封装起来,并且仅仅提供远程调用计算资源的功能,我们就可以称其为Web API。

有很多方式和规则可以设计这些Web API:

  • 简单对象访问协议(SOAP, Simple Object Access Protocol)为表示远程服务调用和响应提供了一种约定。如果一个网络服务遵守SOAP约定,我们就成该网络服务为SOAP网络服务或者SOAP网络API(SOAP Web Service or SOAP Web API)。

  • 表征状态转移(Representational state transfer, REST)是一组针对网络应用程序设计的框架约束(不是一个协议或某种标准)。因为网络服务也是一种网络程序,我们可以将REST约束应用到网络服务的设计中。一旦一个网络服务遵守了REST的概念,我们就可将其称为RESTful网络服务或者RESTful网络应用程序接口RESTful Web Service or RESTful Web API)。

这与我们将一个局部变量简单地称呼为变量,将一个参数变量称呼为参数一样,我们总是将SOAP网络服务( SOAP Web Service)简称为网络服务(Web Service),将RESTful网络服务(RESTful Web Service)简称为Web API。这暗示大多数现代的Web API倾向于适应REST概念作为他们的设计原则。

至于REST是什么,那就敬请期待微信公众号以及CSDN上后续的文章推送了。

英文原文

What is the Web?

NOTE: This content is at a very basic level. You may skip this topic if you are already familiar with these concepts.

Nowadays, networking and the Internet are very popular. Software running on different computers can "talk" to each other. The "languages" used by software to "talk" are protocols. You may have heard about protocols such as TCP, HTTP, FTP, etc.

The Web is a group of computers in a network, and they communicate with each other through HTTP protocol, typically. The Web can be big or small, for example:

  • On an intranet of a company, if there are some computers that communicate with each other through HTTP and share documents via a web browser, that can be considered a SMALL web.

  • On the Internet, billions of computers and devices communicate through HTTP, forming a BIG web. As a matter of fact, it is one of the largest things on the Earth - the World Wide Web.

What is a Web Server

Usually, when software is communicating across a network, the role of each software application may be different. If an application holds the resources, such as data or program logic, and can provide these resources to other applications, we refer to the application, and the computer, as a server. In contrast, if the application does not have the resources it needs, it has to request the resources from other applications through the network. We call this role a client.

If an application can provide data and/or computing power across a web, we call it a web server. Because the computers/devices on a web are connected by HTTP protocol, we can easily infer that a web server must provide/expose resources through HTTP protocol.

There are a variety of resources the web server can provide to the web clients, but we can categorize resources into just two categories - data and computing power. Data can be represented by many things on the server, such as an HTML page, a PNG image, an MP3/MP4 file or a bunch of records in a database. Computing power means the computing ability of a server. Servers can typically offer greater computing resources than a client may possess, depending on the computer hardware used.

The client can send parameters to the server through requests. After the server accepts the parameters and executes a computation of some sort, it returns the result back to the client through a response.

  • If a web server provides data resources, and the data are in HTML format (we know a browser can render HTML content), we call this web server resource a Website.

  • If a web server provides a data resource, and the data is serialized in XML, JSON or other formats, we call this a Data Web Service or Data Service.

  • If a web server provides computing power resources, which means the web client can invoke the computing power on the web server remotely, and the web server will respond with the computing result (in proper format), we call this web server Web Services or Web API
    As you may notice, regardless of the type of resources, there must be some result or data in the response to the client. The result data proves the existence of resources on the server, and we call these data the representation of resources.

What is Web API

API stands for Application Programming Interface. An API is critical for referencing and invoking members in class libraries. If you want to use the members in class libraries successfully, your code must comply with the API defined by the developer of those class libraries.

After referencing a class library, the application can easily call or utilize the functionality of the class library on a single computer. The real problem is when the application and class library are not on the same computer. How do we make a call to an API on a different computer than our client?

There are several generations of solutions for this problem, such as Remote Procedure Call (RPC), Common Object Request Broker Architecture (CORBA), etc. Eventually, developers grafted remote calls onto web servers. This results in the class libraries residing on the web server and exposing the API of class libraries through the HTTP protocol.

In this way, web servers centralize the computing power and publish it as web services, while the web clients consume the computing power remotely. Since the web clients are still calling the API of the class libraries but remotely through the web, we call this kind of web service, Web API. In short, if a web service acts as the wrapper of class libraries and just exposes remote computing ability, we call it Web API.

There are many styles and rules for designing these web APIs,

  • Simple Object Access Protocol (SOAP) provides a convention for representing remote procedure calls and responses. If a web service adopts SOAP, we call this web service a SOAP Web Service or SOAP Web API.

  • Representational state transfer (REST) is a set of architectural constraints (NOT a protocol or standard), for web application design. Since a web service is a kind of web application, we can apply REST constraints to the design of web services. Once a web service adopts REST concepts, we call it a RESTful Web Service or RESTful Web API.

In much the same way that we simply call a local variable, "variable", and call a parameter variable, "parameter", we always simplify the name SOAP Web Service to Web Service, and the RESTful Web Service to Web API. This implies that most of the modern Web APIs tend to adopt the REST concept as their design principle.

文献来源

  1. edX Build Web APIs using ASP.NET Course  Module 1 | Introduction to Web API  Lesson One: What is Web API?  What is Web API?

及时获取我发的文章,学习更多编程知识欢迎关注我的个人微信公众号:

什么是Web?Web Service、Web API傻傻分不清楚?相关推荐

  1. web server and web service

    问题:Web Service和Web Server的区别? 1. 概念上有什么不同? 2.   开发上有什么不同? 3. 哪些服务器支持web server ? 哪些支持web service? 4. ...

  2. odoo系统的web服务器,Odoo Web Service API

    Odoo Web服务暴露出相关的服务,路由分别是 /xmlrpc/ /xmlrpc/2/ /jsonrpc 根据 services 调用 后端对应服务的 方法method [定义 openerp\ht ...

  3. Selenium Web 自动化 - Selenium常用API

    Selenium Web 自动化 - Selenium常用API 2016-08-01 目录 1 对浏览器操作   1.1 用webdriver打开一个浏览器   1.2 最大化浏览器&关闭浏 ...

  4. web service(web服务)总结

    由于开发需要用到接口, 想到了web service 以前了解过web service 但是没有实际写过, 今天就工作需要写一篇示例, 谨以为后学之人提供一点了解途径. 首先 说明的是我用的开发环境是 ...

  5. web project、web service project和java project的区别

    java project就是普通的用java写的程序,直接就能运行的,web project,web service project不能直接运行,必须在容器里面运行,这个容器就是web server, ...

  6. “已使用指定的进程(“Web Management Service”)连接到远程计算机,但未能验证服务器的证书”的解决方案

    本文由 比特飞 原创发布,欢迎大家踊跃转载. 转载请注明本文地址:"已使用指定的进程("Web Management Service")连接到远程计算机,但未能验证服务器 ...

  7. 百度地图WEB服务-地点检索API

    百度地图WEB服务-地点检索API 行政区划区域检索 圆形区域检索 矩形区域检索 地点检索服务(又名Place API)是百度地图开放平台提供的Web API接口服务: 该服务提供多种场景的地点(PO ...

  8. 计算机网络服务无法启动,电脑遇到Windows无法启动world wide web publishing service服务,依赖服务或组无法启动怎么办-电脑自学网...

    电脑遇到Windows无法启动world wide web publishing service服务,依赖服务或组无法启动怎么办?最近有用户在使用IIS站点时,遇到不能启用world wide web ...

  9. 8 OGC Web Feature Service

    第8章 OGC Web Feature Service WFS标准定义了一套对地理要素访问的接口和支持事务的框架,且以独立于底层数据源的方式提供.用户通过WFS提供的操作对空间或属性数据进行查询,设置 ...

最新文章

  1. 使用面向 iOS 的本机插件扩展 PhoneGap
  2. 男孩子学机电一体化好还是计算机好,男孩子上完初中学什么专业好 什么专业有前途...
  3. Navicat 9如何连接ORACLE10G数据库
  4. javaweb宿舍管理系统源码_宿舍信息管理系统展示
  5. Design Patterns(设计模式-发布/订阅)
  6. 二分查找算法的递归、循环实现及其缺陷
  7. linux系统修改用户名密码忘记,Linux下修改/找回root密码
  8. 稀疏编码: LASSO,近端梯度优化(PGD),迭代软阈值算法(ISTA),L-Lipschitz条件,软阈值
  9. java 向下转型运行时错误_java多态和向下转型问题。
  10. js 字符串去除空格
  11. Trapcode Particular 5(合集·中英对照)
  12. Matlab实现数字图像处理——滤波
  13. pandas+matplotlib——习题一
  14. java jmf变成_java JMF 多媒体
  15. 无法识别的USB设备跟这台计算机连接的前一个USB设备工作不正常,Windows无法识别它
  16. bootstrap-select 插件示例
  17. Linux 硬盘与硬件管理
  18. 实现数组扁平化的 6 种方式
  19. 启动项目打开出现缓存,浏览器清空都清除不掉的解决办法
  20. 来自腾讯无线研发的经验分享

热门文章

  1. mmdetection训练 显卡选择
  2. 在线观看北京奥运会直播 在网上看奥运会直播
  3. 使用JavaReport制作Web报表与图形 入门示例
  4. KF、EKF、ESKF的区别与联系
  5. 读懂DeFi四大金融原语的演变:流动性、杠杆、风险和套利
  6. ulimit -u
  7. 怎样获得手机的外网ip???
  8. 蓝桥杯嵌入式定时器输出PWM(可调占空比)
  9. 信息系统基础知识---信息系统工程
  10. SAP-MM知识精解-常见报表汇总(01)