WCF 与 ASP.NetWebAPI

使用每种技术的优点和缺点是什么?

WCF Web Api 现在合并到 Asp.net 中 Net web api 现在支持自托管。

我仍然可以想象,如果我想为同一个操作公开多个协议模式,我仍然倾向于 WCF,或者 Mvc 端点也可以这样做吗?

还有新的 Asp。网络应用程序接口暴露 Wsdl? ?如果没有,客户端将如何找出什么操作可用于他们?

可以说 Mvc 最好的特性是建模绑定器?

那么,谁能告诉我 Asp.net web api 带来了什么优势?WCF 似乎是压倒性的更强大/可伸缩的选择,imo。Mvc Web Api 对于 WCF 模型的唯一优势可能是易于开发,但是如果它最终成为一个严重的设计限制,那就意味着一文不值。

46504 次浏览

The WCF Web API primarily focuses on REST implementations. If you are setting up a REST implementation, the standard WCF bits are a bit of a pain in the rear. If you are setting up RESTful services, you will find the WCF Web API a much nicer experience. If you are setting up SOAP services, then the WCF Web API is not your best friend, and you are better off using WCF for your services.

First, I suggest you read my post on the subject: http://blogs.microsoft.co.il/blogs/idof/archive/2012/03/05/wcf-or-asp-net-web-apis-my-two-cents-on-the-subject.aspx

Regarding your WSDL question - since the WebApi does not use SOAP, it does not require a WSDL, and does not export one. You can use Hypermedia to return resources with a list of possible activity URLs (think of it as a self-describing resource)

The choice depends on what we want to do.

  1. ASP.NET Web API is a framework for building non-SOAP based services over HTTP only - so there aren't more transport protocols available using this framework.
  2. WCF / Windows Communication Foundation is a framework for exchanging SOAP-based messages - here we use a lot of transport protocols: HTTP, TCP, Named pipes, MSMQ, etc...

I am not sure about which one has better performance regarding the amount of data, maybe WCF since we can use low protocols. Any comments are appreciated.

Use WCF for intranet/B2B sites n Web API for B2C/C2C/internet sites...SOAP/XML is still the standard for intra-businesses communication n it's not going to go away!!!