简体   繁体   English

WCF,Web服务或ADO.NET数据服务:我应该使用什么?

[英]WCF, Web services or ADO.NET data services: What shall I use?

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. 对于一个项目,我必须在Web服务器上托管的数据库和互联网上的几个客户端之间实现通信。 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) 1)Windows Communication Foundation(WCF)
2) ASP.NET Web services 2)ASP.NET Web服务
3) ADO.NET Data services 3)ADO.NET数据服务

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). 在客户端,这不会由在浏览器中工作的用户以交互方式发生,而是作为客户端上的自动进程定期运行(例如每2小时)。

a) On web server side there will be: a)在Web服务器端,将有:

  • A SQL Server database SQL Server数据库
  • .NET Framework 3.5 SP1 .NET Framework 3.5 SP1
  • A class library representing the database structure and modeled with ADO.NET Entity Framework 表示数据库结构并使用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.) (一个ASP.NET Web应用程序,它将在浏览器中显示数据库中的数据:我把它放在括号中,因为这个Web应用程序并不重要,因为上面提到的数据上传/下载不会通过浏览器GUI触发。)

b) The client side is less clear and must be more flexible. b)客户方不太清楚,必须更灵活。 Here I have to distinguish between two requirements: 在这里,我必须区分两个要求:

i) Priority One (in terms of the time I have available for development): i)优先级一(根据我可用于开发的时间):

  • 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. 客户端在我的控制之下,这意味着:我在客户端上有任何Windows操作系统,我可以安装.NET Framework,我可以决定开发Windows服务,控制台应用程序,Windows窗体应用程序等等。 And I have knowledge about and access to the class library mentioned above. 我对上面提到的类库有所了解和访问。

ii) Lower Priority, but must be a future option: ii)优先级较低,但必须是未来选项:

  • 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). 其他人将开发的客户端可以使用任何类型的操作系统(Windows,UNIX,MacOS等)进行操作。 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. 由于最后一点迫使开发人员在客户端使用.NET Framework不是一种选择。 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). 在我的小研究中,我正在阅读“SOAP”,“REST”或“AtomPub”等术语,这些似乎是一种标准协议或通信技术(不是微软的专有发明)。 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)? (1),(2)或(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. (2)旧式ASP.NET Web服务即将问世 - 它已经过时,不再开发 - 它已被WCF取代。

So this leaves options 1 (straight WCF) and 3 (ADO.NET Data Services - renamed WCF Data Services recently). 所以这留下了选项1(直接WCF)和3(ADO.NET数据服务 - 最近重命名为WCF数据服务)。

Both use WCF as their basic technology - so learning and knowing about WCF is a must in both cases. 两者都使用WCF作为他们的基本技术 - 因此在这两种情况下都必须学习和了解WCF。

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. 使用直接WCF(选项1),您可以选择更多选项 - 您可以自行托管,在IIS中托管服务,使用不同的协议和绑定等等。 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. 您的客户需要能够与您交谈 - 几乎任何语言(当然,.NET,Java,Ruby,PHP - 您的名字)都可以用这种或那种方式谈论SOAP。

If you're mostly interested in exposing data from databases onto outside clients, I think WCF Data Services is indeed quite a good choice. 如果您最感兴趣的是将数据从数据库公开到外部客户端,我认为WCF数据服务确实是一个不错的选择。 It's based on REST, so you can hit your WCF Data Service with a browser and just see what happens. 它基于REST,因此您可以使用浏览器访问WCF数据服务,看看会发生什么。 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. 它非常强大,甚至提供LINQ客户端支持 - 您可以制定LINQ查询,并将其转换为对数据服务的相应REST调用。

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. 使用WCF数据服务,您的客户端只需要一个HTTP堆栈 - 甚至iPhone也有:-)但是使用.NET客户端,事情当然更好,更舒适,更高效。

I'd say check out the WCF Data Service first and see if that satisfies your needs - and if not, dig deeper into WCF. 我首先要检查WCF数据服务 ,看看它是否满足您的需求 - 如果没有,请深入研究WCF。 Also check out WCF Data Service at a glance for an intro. 同时查看WCF数据服务一目了然

UPDATE: 更新:

Marc, do I understand you correctly that WCF on the server fulfils this requirement? Marc,我是否理解您服务器上的WCF是否满足此要求? And ADO.NET (WCF) Data services too? 和ADO.NET(WCF)数据服务呢?

Absolutely. 绝对。 WCF (plain or with Data Services) on the server side does NOT dictate the client in any way, shape or form. WCF(平原或与Data Services)在服务器端没有规定以任何方式,形状或形式的客户端。 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. 如果您真的喜欢它,您可以将iPhone连接到WCF数据服务:-) WCF从一开始就设计为非常可互操作 - 实际上,它是实现最多WS- *行业的一个平台跨平台通信标准。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM