我需要WCF,如果我可以使用ASP.net的Web API [英] Do I need WCF if I can use ASP.net Web API

查看:114
本文介绍了我需要WCF,如果我可以使用ASP.net的Web API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我读了很多关于ASP.net的Web API。难道我的理解对不对,如果我需要一个WebService只需要HTTP作为交通工具,我可以去ASP.net API,不需要WCF?
到目前为止,它看起来好像网络API是容易得多WCF使用。

today I read a lot about ASP.net Web API. Do I understand it right, that if I need a WebService that only needs HTTP as transport, I can go for ASP.net API and don't need WCF? So far it looks as if Web API is much easier to use than WCF.


托马斯

推荐答案

在回答你的问题基本上是肯定的。如果您在)只是想使用HTTP,B)想你的内容返回的XML或JSON,C),要使用一个RESTful API和d)不需要任何先进的通讯功能,则Web API是你最好的选择。正如你指出,这是很容易比WCF使用。

The answer to your question is basically yes. If you a) just want to use HTTP, b) want your content returned as XML or JSON, c) want to use a RESTful API and d) don't need any advanced messaging functionality, then web API is your best bet. As you point out, it is much easier to use than WCF.

当你创建一个Web服务,您有两个基本的选择:基于SOAP的服务或一个RESTful API。如果您使用的是基于SOAP的服务,您应该使用WCF。如果您正在使用RESTful服务,你应该使用Web API。你可以看到有关此进一步讨论此博客文章:
<一href=\"http://blogs.microsoft.co.il/blogs/idof/archive/2012/03/05/wcf-or-asp-net-web-apis-my-two-cents-on-the-subject.aspx\" rel=\"nofollow\">http://blogs.microsoft.co.il/blogs/idof/archive/2012/03/05/wcf-or-asp-net-web-apis-my-two-cents-on-the-subject.aspx

When you create a web service you have two basic option: a SOAP-based service or a RESTful API. If you are using a SOAP-based service you should use WCF. If you are using a RESTful service you should use the Web API. You can see this blog posting for further discussion about this: http://blogs.microsoft.co.il/blogs/idof/archive/2012/03/05/wcf-or-asp-net-web-apis-my-two-cents-on-the-subject.aspx

顺便说一句,无论你选择SOAP或REST取决于你的情况的细节。一些常规准则如下:

As an aside, whether you choose SOAP or REST depends upon the details of your situation. Some general guidelines are as follows:

有利于SOAP服务的因素:


  • 您只是服务的消费者,还是也有宇宙有限
    消费者

  • 高级功能,如交易的WS-Security,
    可靠的消息传递等,都需要

  • 服务必须在HTTP之外其他传输,如TCP,MSMQ,命名管道等暴露出来。

  • 功能暴露不容易映射到实体或者集合CRUD操作

  • 您需要的复杂类型的强类型支持

  • 网络带宽问题不是问题

有利于RESTful服务的因素:


  • 服务必须由大量客户端(即互联网)消耗

  • 高级功能,如交易,WS-Security的,可靠的消息传递等,不是必需的

  • 接受的服务,可以通过HTTP仅暴露

  • 功能轻松映射到CRUD操作的实体或者集合

  • 您需要其他媒体类型,如JSON或YAML支持

  • 网络带宽问题,代价

编辑:
在回答您的意见,如果你使用WCF / SOAP,你能使用多种由SOAP支持的功能。这包括诸如事务,可靠消息,各种消息传递模式(单向,双工等)和WS-Security。这些标准是由的OASIS标准身材维护,并通常被称为WS- *。在WS- *标准可查阅名单 rel=\"nofollow\">。

In response to your comment, if you use WCF/SOAP, you get to use the wide range of functionality that is supported by SOAP. This includes things like transactions, reliable messaging, various messaging patterns (one-way, duplex, etc) and WS-Security. These standards are maintained by the OASIS standard body and are commonly referred to as WS-*. A list of the WS-* standards can be found here.

如果您正在使用Web API / REST,你不能使用任何的WS- *功能。然而,它仍然是可能的认证,并使用在IIS和AS​​P.Net可用标准的认证技术授权访问RESTful服务。有关更多信息,请访问以下链接:

If you are using Web API/REST, you cannot use any of the WS-* functionality. However, it is still possible to authenticate and authorize access to RESTful services using standard authentication techniques available in IIS and ASP.Net. For more information on this, see the following links:

http://$c$cbetter.com/johnvpetersen/2012/04/02/making-your-asp-net-web-apis-secure/

http://stevescodingblog.co.uk/basic-authentication -with-ASP净的WebAPI /

和一些博客文章的。

这篇关于我需要WCF,如果我可以使用ASP.net的Web API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆