The Enterprise Service Realization
By late 2010, enterprise software architects are realizing that SOAP-based WCF endpoints are too heavy for client-side JavaScript applications and early mobile apps. Developers want lightweight, RESTful JSON services.
Microsoft's early response, ASP.NET AJAX PageMethods or WCF WebHttpBinding, felt like clunky patches on top of frameworks designed for other paradigms.
Microsoft's new project—WCF Web API (currently in preview)—represents a dedicated, first-class HTTP programming engine.
What is WCF Web API?
WCF Web API is a lightweight framework designed to build clean HTTP endpoints. Unlike SOAP-based WCF services, WCF Web API exposes HTTP resources directly:
1. Unified Route Registration
Instead of complex XML configurations, paths are registered programmatically:
// Early route configuration in WCF Web API
routes.Add(new ServiceRoute("api/users", new HttpServiceHostFactory(), typeof(UserService)));2. Built-in Content Negotiation
Clients can specify their desired payload format using the HTTP Accept header (e.g. Accept: application/json or Accept: application/xml). The framework automatically serializes the returned C# object matching the request header format.
3. Native HTTP Objects
Direct control over HTTP status codes, headers, and responses:
[WebGet(UriTemplate = "{id}")]
public HttpResponseMessage<User> GetUser(string id) {
var user = _repository.Find(id);
if (user == null) {
return new HttpResponseMessage<User>(HttpStatusCode.NotFound);
}
return new HttpResponseMessage<User>(user);
}The Future: Merging into ASP.NET Web API
This preview work is laying the foundation for what will eventually become ASP.NET Web API, establishing a clean REST service framework in .NET architectures.