This project is read-only.

WCF Web API vs WCF Service

Topics: Web Api
May 12, 2011 at 10:30 AM
Edited May 12, 2011 at 10:31 AM


I need to create a web service and I want to use WCF.  I just need to call a couple of methods which will return either an object or a list of objects.

Would you recommend using the WCF Web API or just implement a "standard" WCF service?  What is the difference between the two?

Thanks in Advance

May 12, 2011 at 12:55 PM

The WEB API is HTTP Specific. The entire framework was designed to work with HTTP and expose anything the HTTP Spec supports. It has extension points for custom formatters and for accessing raw http. Configuration is through a fluent HttpConfiguration class

In WCF you can choose from several different binding using different transports. Is ideal for cases where you want to expose a service over multiple transports including SOAP. 

May 12, 2011 at 1:04 PM

Thanks for the response.  I only want to expose this to a single type of client and use json.  How would I configure this using the Web API?  Also, how do you create the client side proxies on the client side (to tell them about the objects) using the Web API?  Can you still add a reference to the WSDL, or as there is no .svc file is there some other mechanism?

Thanks again.

May 12, 2011 at 2:02 PM

I would download the code and look at the ContactManager simple then advanced. They demonstrate everything you need for your case. JSON is handled out of the box.  There is no .svc file or WSDL and I'm not sure why you would need them using JSON.  What is your client going to be? You can use HttpClient when calling your services from managed code or JQuery should have no problem making calls.{examples in ContactManager sample}