WCF Data Services (OData) Vs ASP.NET Web API

后端 未结 8 631
鱼传尺愫
鱼传尺愫 2021-01-29 21:01

I am designing a distributed application that will consist of RESTful services and a variety of clients (Silverlight, iOS, Windows Phone 7, etc). Right now I\'m determining whi

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-29 21:31

    This is the TL;DR answer to this question.

    WCF is the swiss army knife to WEB API's screwdriver for data communication and transfer: WCF can do everything WEB API can do, but, if you need more (e.g., using TCP protocol), WCF is the way to go.

    Here is a great comparison.

    WEB API

    Number one reason to use WEB API is that it is lightweight. This means it is simpler to implement, easier to learn, easier to maintain, etc. It is specifically designed for the Web, which needs RESTful web services over HTTP. It does this and it does it well. If, this is all you need, WEB API is probably the way to go.

    Also, it is Open Source (if you care)

    WCF

    WCF just does a lot more than WEB API: it supports multiple transfer protocols, multiple exchange patterns (WEB API requires integration with SignalR or Web Sockets), SOAP services can be described in WSDL, has additional security features, and more. Go with WCF if you require this additional functionality.

    OData

    OData is simply

    An open protocol to allow the creation and consumption of queryable and interoperable RESTful APIs in a simple and standard way. source: http://www.odata.org/

    In other words, high level, it is just standardizing a specific grammar for RESTful HTTP requests. Which will provide the same benefits as any protocol. And as of at least 2013 both WCF and WEB API allow the use of OData. So, it probably isn't worth worrying about OData.

提交回复
热议问题