WCF Web API FAQ

Q: Is WCF Web API a replacement for WCF in .NET 4.0?

A: No, WCF Web API is an evolution of the work we have done since .NET 3.5 for supporting HTTP services in WCF.

Q: Is WCF Web API a replacement for the REST starter kit?

A: Yes, the new work we are doing ultimately replaces the REST Starter Kit and is being incorporated in the platform. Beginning with .NET 4.0 we started to port features from the starter kit into WCF proper. With this release we will fill the gaps that remain as well as add a bunch of new functionality including an improved HTTP client and a significantly overhauled model for making it easier to  work with HTTP on the server.

Q: Are there any breaking changes between WCF HTTP in .NET 4.0?

A: Yes, but the experience should feel similar and migration is straightforward. The primary breaking change is you can no longer access the static WebOperationContext.Current property for getting access the HTTP headers and body. In the new API you will use parameters of type HttpRequestMessage and HttpResponseMessage in within your method to access the underlying message. The advantage of this new approach is it provides more rich access to work with HTTP, and it makes the code easier to test.

Q: Can I expose a service created with WCF Web API over a SOAP Transport?

A: You can as long as you do not use HTTP specific features like accessing the new HTTP Request and Response messages via your method calls. Supporting SOAP is not a goal thus your services will be limited in terms of their capabilities of working directly with HTTP if you use the new web APIs.

Q: Can I use WCF Web API with ASP.NET / ASP.NET MVC?

A: Yes, you can host HTTP services within an ASP.NET site. With MapServiceRoute<T> we also allow you to register routes for Web APIs along with other routes like MVC.

Q: Can I use WCF Web API in Silverlight?

A: Currently we do not have any support for Silverlight. You can however consume HTTP resources in Silverlight using HttpWebRequest.

Q: I build sites in ASP.NET MVC and I find it is really easy to use MVC to expose functionality over HTTP for example using a JsonResult for AJAX clients, why should I use this over MVC?

A: While ASP.NET MVC works well for simple Web APIs, it is primary intended for building websites. WCF Web API is designed specifically to help you create HTTP-based Web APIs that can reach the broadest array of clients (browsers, phones, tablets, desktop). With WCF Web API you get rich, high-level HTTP programming model that includes full support for content negotiation, a variety of popular formats (XML, JSON, OData), server-side query composition, etags, hypermedia and much more. Going forward we envision a great degree of integration between WCF Web API and ASP.NET MVC that will allow developers using either platform to take advantage of these great features.

Q: Can I use the code on this site in production?

A: The current license allows you to deploy the code within your own environments, this includes exposing Web APIs on your company’s web servers or their hosting providers. It does not allow you to redeploy the code such as HttpClient within a product or to other customers.

Q: Can I fork the code?

A: Yes you can fork the code for internal use.

Last edited Sep 15, 2011 at 9:26 PM by danroth27, version 10

Comments

tarun1982 Apr 11, 2012 at 2:26 PM 
Can i use in Windows Application(WinForm)?

tarun1982 Apr 11, 2012 at 2:26 PM 
Can i use in Windows Application(WinForm)?

SoftInvent Apr 7, 2011 at 1:24 PM 
Can you reveal any plans for RTW/RTM of the Web APIs, especially WCF HTTP?