Announcement:
WCF Web API is now ASP.NET Web API!
ASP.NET Web API released with ASP.NET MVC 4 Beta. The WCF Web API and WCF support for jQuery content on this site wll removed by the end of 2012.
WCF Web API Overview
What is WCF Web API?
Applications are continually evolving to expose their functionality over the web for example social services like
Flickr, Twitter and
Facebook. Aside from social applications, organizations are also looking to surface their core enterprise business functionality to an ever expanding array of client platforms. WCF Web API allows developers to expose their
applications, data and services to the web directly over
HTTP. This allows developers to fully harness the richness of the HTTP as an application layer protocol. Applications can communicate with a very broad set of clients whether they be browsers, mobile devices, desktop applications or other backend services.
They can also take advantage of the caching and proxy infrastructure of the web through providing proper control and entity headers. We are designing specifically to support applications built with a
RESTful architecture style though it does not force developers to use REST. The benefits of REST for your applications include discoverability, evolvability and scalability.
Click here to access our
FAQ.
Quick Start
Architecture overview
Below is a high level diagram of the WCF Web API architecture

HTTP Client– WCF Web API introduces a new HTTP client (HttpClient) for sending HTTP requests and receiving HTTP responses. The new client has been built very tightly in accordance with the
HTTP specification and allows developers to consume any HTTP service. WCF Web API also adds a set of extension methods for simplifying the conversion of the HTTP body to and from .NET classes. The
HTTP client provides HttpRequestMessage and HttpResponseMessage abstractions, which are strongly typed representations of an HTTP message. WCF Web API uses these new types the server as well for a fully symmetric experience.
Listener – This component listens over HTTP and accepts an incoming HTTP message. The listener has a specific base address like “http://www.contoso.com” that it monitors incoming traffic on.
HTTP Channel stack – WCF Web API is agnostic to the hosting environment as it can be hosted on ASP.NET, directly on IIS or self-hosted in a desktop front end, or a backend process like a windows service. At the hosting later we transform
the raw incoming HTTP message into our new HttpRequestMessage and we transform outgoing HttpResponseMessage instances into a raw HTTP response. At the channel layer low level concerns can be addressed such as plugging in an OAuth channel for handling security,
or logging of all messages. The new HttpMessageHandler API provides a simple to use extension point for developers to easily plug in such concerns.
Dispatcher – The dispatcher is responsible for routing the current http request to an http service instance and a method on that service. The service and method are matched based on the URI and HTTP method (GET, POST, PUT, DELETE,
etc). At this layer serialization is also handled, allowing the body of the HTTP message or other components to be transformed to and from .NET types. In WCF Web API we’ve introduced a new extensibility point called MediaTypeFormatter which allows developers
to easily plug in their own media type format support(including those that support hypermedia) which can act on both the body as well as other components of the message like the URI. Media type formatters can also be used for addressing other cross-cutting
HTTP concerns like ETags. Processors are also designing to easily testable.
HTTP Service – The service is the place where developers add custom handling code and business logic for an HTTP request. With WCF Web API developers can get direct access to the underlying HTTP request and response through parameters
on the operations rather than through static APIs (like WebOperationContext). The new request and response message types make WCF Web API much easier to unit test.
*For those familiar with WCF this may look similar to diagrams you have seen of our previous releases. The primary difference here is that the components within the various layers are now specific to HTTP.
Features
- First-class programming model for HTTP in WCF
- Access HTTP from top to bottom
- Content negotiation
- HttpClient
- Out of the box support for XML, JSON and OData
- Typeless JSON support – Allows using a dynamic object on the server for accessing the body. Useful for jQuery clients.
- Plug in any format / media type
- IQueryable support – Supports OData’s URI format for services
- Designed for better separation of concerns and testability
- Validation, URI model binding, caching, etags, etc
- Easily integrate your IoC container
- Simple code-based configuration model
- Support for HTTP file upload and MIME-based batching
- Integrated Web API test client
Team Blog posts
External resources
We hope you enjoy using WCF Web API. Your feedback is greatly appreciated!