API和web API

API

Apis (Application Programming interfaces) are predefined functions designed to provide applications and developers the ability to access a set of routines based on a piece of software or hardware without having to access source code or understand the details of the internal workings.

Web API

ASP.NET Web API是一个框架,它使构建HTTP服务变得很容易,这些服务可以到达广泛的客户端,包括浏览器和移动设备。ASP.NET Web API是在.NET框架上构建基于rest的应用程序的理想平台。

目的:

Web API最重要的是可以构建面向各种客户端的服务。另外与WCF REST Service不同在于,Web API利用Http协议的各个方面来表达服务(例如 URI/request response header/caching/versioning/content format),因此就省掉很多配置。

功能简介
1、支持基于Http verb (GET, POST, PUT, DELETE)的CRUD (create, retrieve, update, delete)操作

通过不同的http动作表达不同的含义,这样就不需要暴露多个API来支持这些基本操作。

2、请求的回复通过Http Status Code表达不同含义,并且客户端可以通过Accept header来与服务器协商格式,例如你希望服务器返回JSON格式还是XML格式。

3、请求的回复格式支持 JSON,XML,并且可以扩展添加其他格式。

4、原生支持OData。

5、支持Self-host或者IIS host。

6、支持大多数MVC功能,例如Routing/Controller/Action Result/Filter/Model Builder/IOC Container/Dependency Injection。

猜你喜欢

转载自www.cnblogs.com/scg0624/p/9975174.html
API