WCF 服务或 Web API [英] WCF Service or Web API

查看:28
本文介绍了WCF 服务或 Web API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将从事一个涉及许多元素的项目:

I'm going to be working on a project that involves a number of elements:

  • ASP.NET MVC 网站
  • C# 控制台应用程序
  • iPhone 应用程序

为了让所有这些独立的应用程序与数据库通信,我的直接想法是使用 WCF 服务.

To get all these separate applications talking to the database, my immediate thought was to use a WCF Service.

但是,我现在需要向站点添加一个 API,以允许第三方从他们自己的应用程序中选择、插入和更新记录.

However, I now need to add an API to the site to allow third parties to select, insert and update records from their own applications.

在我看来,我只会在我的 WCF 服务上创建一个单独的 RESTful 服务端点,该端点将使用身份验证锁定,并且只能访问某些方法.

In my mind, I would just create a separate RESTful service endpoint on my WCF Service which would be locked down using authentication and would only give access to certain methods.

但是,我今天一直在阅读有关 MVC 4 中的 Web API 功能的内容,该功能旨在成为 RESTful API 的最新功能?

However, I've been reading today about the Web API feature in MVC 4 which is meant to be the latest thing for RESTful APIs?

我应该继续使用 Web API 吗?或者因为我的其他应用程序需要 Web 服务,我应该坚持使用 WCF 服务吗?

Should I be going along the line of using the Web API? or because my other applications need a web service, should I stick with a WCF Service?

推荐答案

如果您打算进行 RESTful 开发,那么您肯定会想要使用 ASP.Net Web Api(最初称为 WCF Web Api 并为目标而创建)使 REST 成为 .NET 中的一等公民".

If you intend to do RESTful development then you will definitely want to use the ASP.Net Web Api (which was originally called WCF Web Api and created with the goal of "Making REST a first class citizen in .NET".

另一件需要考虑的事情是 WCF REST 入门工具包不再受支持.

Another thing to consider is that the WCF REST Starter kit is no longer supported.

请注意,使用 Web Api 并不意味着您必须使用 ASP.Net MVC 或 IIS,即使它可以是 自托管.

Note that using Web Api doesn't mean you have to use ASP.Net MVC or IIS even as it can be self hosted.

对于处理本质上非 CRUD 的操作,我建议使用谷歌搜索REST non-CRUD".我发现这篇博文 RESTful URLs for non-CRUD操作(尤其是有趣的评论).如果您决定需要进行 RPC 调用,那么这些可能必须使用 WCF 来完成.也就是说,由于 WCF REST 被淘汰,我不确定最好的解决方案是什么.两者兼而有之可能是最好的答案,但同时也不一定是好的答案.

For handling operations which are non-CRUD in nature I'd recommend Googling "REST non-CRUD". I found this blog post RESTful URLs for non-CRUD operations (and particularly the comments interesting). If you decide you NEED to have RPC calls then those may have to be done with WCF. That said since WCF REST is being killed off I'm not sure what the best solution is going to be. Having both is probably the best answer but at the same time it's not necessarily a good answer.

另一种选择是 WCF OData 服务,但我不确定它是否得到 iPhone 的任何支持.

Another alternative would be a WCF OData Service but I'm not sure if that gets any support from an iPhone.

最后一点要说明(以后可以删除,因为时间敏感)

Microsoft 提供了带有 Beta 版的 Go Live 许可证,这意味着它受 Microsoft 支持,升级到文件 RTM 应该没有任何问题.

Microsoft has provided a Go Live license with the beta which means that it is supported by Microsoft and you shouldn't have any problems upgrading to the file RTM.

这篇关于WCF 服务或 Web API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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