web服务和API之间的区别是什么?差异是否超过了传输数据所使用的协议? 谢谢。


当前回答

一般来说,web服务是一个基于HTTP的API。它们通常使用JSON或XML,但也有一些其他方法。

其他回答

把Web服务看作Web api。API现在是一个通用术语,因此web服务是功能的接口,通常与业务相关,您可以通过各种协议从网络获得它。

API是基于代码的集成,而web服务是基于消息的集成,与具有WSDL等契约的可互操作标准进行集成。

API是一个已发布的接口,它定义了组件a如何与组件B通信。

例如,Doubleclick发布了一个Java API,允许用户查询数据库表以获得有关其在线广告活动的信息。

例如,调用GetNumberClicks(用户名)

要实现API,必须将双击.jar文件添加到类路径中。这是本地呼叫。

web服务是API的一种形式,其中接口是通过WSDL定义的。这允许通过HTTP远程调用接口。

如果Doubleclick将其接口实现为web服务,那么他们将在Tomcat中使用类似Axis2的东西。

远程用户将调用web服务

例如调用GetNumberClicksWebService(用户名)

GetNumberClicksWebService服务将在本地调用GetNumberClicks。

另一个例子:谷歌地图api vs谷歌方向api web服务,前者服务(交付)javascript文件到站点(然后可以用作api来制作新功能),后者是一个Rest web服务交付数据(json或xml格式),可以处理(但不用于api意义上)。

API(应用程序编程接口),完整的形式本身表明它是一个接口,允许你在其他应用程序接口的帮助或支持下为你的应用程序编程,它公开了一些对你的应用程序有用的功能。

E.g showing updated currency exchange rates on your website would need some third party Interface to program against unless you plan to have your own database with currency rates and regular updates to the same. This set of functionality is when already available with some one else and when they want to share it with others they have to have an endpoint to communicate with the others who are interested in such interactions so they deploy it on web by the means of web-services. This end point is nothing but interface of their application which you can program against hence API.