WCF、Web 服务或 ADO.NET 数据服务:我应该使用什么? [英] WCF, Web services or ADO.NET data services: What shall I use?

查看:32
本文介绍了WCF、Web 服务或 ADO.NET 数据服务:我应该使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个项目,我必须实现托管在 Web 服务器上的数据库与 Internet 上的多个客户端之间的通信.在阅读了一些内容并观看了一些关于可能的 (Microsoft) 技术的介绍性视频后,我发现我似乎(至少)有三个选择:

1) Windows 通信基础 (WCF)
2) ASP.NET 网络服务
3) ADO.NET 数据服务

因为我不熟悉这三种技术中的任何一种,所以我必须(希望只)深入学习其中一种技术 - 问题是:哪一种?

或者更准确地说:以下任务是哪一项?

数据需要从客户端上传到服务器/数据库,还需要下载一些其他数据.在客户端,这不会由在浏览器中工作的用户交互地发生,而是作为客户端上的一个自动过程,该过程将定期运行(例如每 2 小时一次).

a) 在 Web 服务器端将有:

  • 一个 SQL Server 数据库
  • .NET 框架 3.5 SP1
  • 表示数据库结构并使用 ADO.NET 实体框架建模的类库
  • (一个 ASP.NET Web 应用程序,它将在浏览器中显示数据库中的数据:我把它放在括号中是因为这个 Web 应用程序并不重要,因为提到的数据上传/下载不会通过浏览器 GUI.)

b) 客户端不太清楚,必须更加灵活.这里我要区分两个要求:

i) 优先级一(就我可用于开发的时间而言):

  • 客户端在我的控制之下,这意味着:我在客户端上有任何 Windows 操作系统,我可以安装 .NET Framework,我可以决定开发 Windows 服务、控制台应用程序、Windows 窗体应用程序或其他任何东西.我了解并可以访问上述类库.

ii) 较低的优先级,但必须是未来的选择:

  • 我需要公开任何类型的接口描述,以允许其他开发人员构建自己的应用程序来上传/下载数据.
  • 其他人将为其开发的客户端可以在任何类型的操作系统(Windows、UNIX、MacOS 等)上运行.此外,他们应尽可能自由地选择自己喜欢的编程语言.

由于最后一点,迫使开发人员在客户端使用 .NET Framework 不是一种选择.客户端的通信必须是可从各种平台和语言访问的任何类型的标准"技术.在我的小研究期间,我正在阅读诸如SOAP"、REST"或AtomPub"之类的术语,这些术语似乎是一种标准协议或通信技术(不是 Microsoft 的专有发明).但我不确定也不知道哪种技术是最新的"、最好的未来"、最常见和众所周知的、最强大的或最容易使用的(从其他可能的角度来看)开发人员!所以问题是我必须支持什么才能让大多数客户端开发人员满意).

最后一点:安全很重要!上传/下载数据必须仅限于专职人员.如果没有适当的凭据,就无法使用或探索界面.

现在最好使用什么技术?(1)、(2)或(3)?为什么要推荐它?

非常感谢您提供任何建议!

解决方案

好吧,不.(2) 老式的 ASP.NET webservices 正在淘汰 - 它已经过时,不再被开发 - 它已被 WCF 取代.

所以这留下了选项 1(直接 WCF)和 3(ADO.NET 数据服务 - 最近更名为 WCF 数据服务).

两者都使用 WCF 作为其基本技术 - 因此在这两种情况下都必须学习和了解 WCF.

使用直接 WCF(选项 1),您有更多选择 - 您可以自托管、在 IIS 中托管您的服务、使用不同的协议和绑定等.但是选择带来了复杂性——你需要学习和了解所有这些东西——至少在某种程度上是这样.您的客户需要能够与您交流 SOAP - 几乎任何语言(当然,.NET,Java、Ruby、PHP - 您能说出它的名字)都可以以一种或另一种方式交流 SOAP.

如果您最感兴趣的是将数据库中的数据公开到外部客户端,我认为 WCF 数据服务确实是一个不错的选择.它基于 REST,因此您可以使用浏览器访问 WCF 数据服务,然后看看会发生什么.它非常强大,甚至提供 LINQ 客户端支持 - 您制定一个 LINQ 查询,然后将其转换为对数据服务的适当 REST 调用.

使用 WCF 数据服务,您的客户端只需要一个 HTTP 堆栈 - 即使 iPhone 也有:-) 但是使用 .NET 客户端,事情当然更好、更舒适、更高效.

我想先查看 WCF 数据服务,然后看看这是否满足您的需求 - 如果不满足,请深入研究 WCF.另请查看WCF 数据服务概览了解介绍.>

更新:

<块引用>

马克,我理解正确吗服务器上的 WCF 实现了这一点要求?和 ADO.NET (WCF) 数据也有服务?

绝对的.服务器端的 WCF(普通的或带有数据服务的)不会以任何方式、形状或形式指示客户端.如果您真的喜欢,您可以将 iPhone 连接到 WCF 数据服务 :-) WCF 从头开始​​设计为非常具有互操作性 - 实际上,它是实现最多 WS-* 行业的一个平台跨平台通信标准.

For a project I have to implement a communication between a database hosted on a web server and several clients out there in the internet. After reading a bit and watching a few introductory videos about possible (Microsoft) technologies I figured out that I seem to have (at least) three options:

1) Windows Communication Foundation (WCF)
2) ASP.NET Web services
3) ADO.NET Data services

Because I am not familiar with any of those three technologies I have to learn (hopefully only) one of them in depth - and the question is: Which one?

Or to be more precise: Which one for the following task?

Data need to be uploaded from a client to the server/database and some other data need to be downloaded as well. On client side this will not happen interactively by an user who works in a browser but rather as an automatic process on the client which will run periodicly (every 2 hours for instance).

a) On web server side there will be:

  • A SQL Server database
  • .NET Framework 3.5 SP1
  • A class library representing the database structure and modeled with ADO.NET Entity Framework
  • (An ASP.NET web application which will present the data in the database in a browser: I put this in brackets here because this web application doesn't really matter since the mentioned data up/download won't be triggered through a browser GUI.)

b) The client side is less clear and must be more flexible. Here I have to distinguish between two requirements:

i) Priority One (in terms of the time I have available for development):

  • The client side is under my control, it means: I have any Windows OS on the client, I can install .NET Framework and I can decide to develop a Windows service, a Console Application, a Windows Forms application or whatever. And I have knowledge about and access to the class library mentioned above.

ii) Lower Priority, but must be a future option:

  • I need to expose any kind of interface description which allows other developers to build their own applications to upload/download data.
  • The clients which others will develop for can be operated with any kind of OS (Windows, UNIX, MacOS and more). Also they shall be as free as possible to select their own prefered programming language.

Due to the last point forcing developers to use the .NET Framework on client side is not an option. The communication on client side must be any kind of "standard" technology accessible from various platforms and languages. I was reading terms like "SOAP", "REST" or "AtomPub" during my little research and these seem to be a kind of standard protocol or communication technology (not a proprietary Microsoft invention). But I am not sure nor do I know which technology is "up to date", has the "best future", is most common and well known, is the most powerful or is the easiest to use (from a viewpoint of those other possible developers! So the question is what I have to support to make most client side developers happy).

One last point: Security is important! Uploading/Downloading data must be restricted to dedicated persons. It should not be possible to use or explore the interface without appropriate credentials.

What technology is the best to use now? (1), (2) or (3)? And why would you recommend it?

Thank you very much in advance for any advice!

解决方案

Well, no. (2) old-style ASP.NET webservices is on its way out - it's old, no longer being developed - it's been replaced by WCF.

So this leaves options 1 (straight WCF) and 3 (ADO.NET Data Services - renamed WCF Data Services recently).

Both use WCF as their basic technology - so learning and knowing about WCF is a must in both cases.

With straight WCF (Option 1) you have more options - you can self-host, host your service in IIS, use different protocols and bindings and so on. But with choice comes complexity - you need to learn and know all that stuff - at least to some degree. Your client needs to be able to talk SOAP to you - just about any language (.NET of course, Java, Ruby, PHP - you name it) can talk SOAP in one way or another.

If you're mostly interested in exposing data from databases onto outside clients, I think WCF Data Services is indeed quite a good choice. It's based on REST, so you can hit your WCF Data Service with a browser and just see what happens. It's quite powerful, and even offer a LINQ client side support - you formulate a LINQ query and this gets translated into your appropriate REST call to your data service.

With WCF Data Services, your client needs nothing but a HTTP stack - even the iPhone has that :-) But with a .NET client, things are of course nicer and more comfortable and more efficient.

I'd say check out the WCF Data Service first and see if that satisfies your needs - and if not, dig deeper into WCF. Also check out WCF Data Service at a glance for an intro.

UPDATE:

Marc, do I understand you correctly that WCF on the server fulfils this requirement? And ADO.NET (WCF) Data services too?

Absolutely. WCF (plain or with Data Services) on the server side does NOT dictate the client in any way, shape or form. You can hook up an iPhone to a WCF Data Service, if you really feel like it :-) WCF has been designed from the ground up to be very interoperable - actually, it's the one platform out there that implements the most WS-* industry standards for cross-platform communications.

这篇关于WCF、Web 服务或 ADO.NET 数据服务:我应该使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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