如何为新的 Silverlight 应用程序在 WCF、REST、POX 和 RIA 服务之间进行选择 [英] How do I choose between WCF, REST, POX and RIA services for a new Silverlight application

查看:47
本文介绍了如何为新的 Silverlight 应用程序在 WCF、REST、POX 和 RIA 服务之间进行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Silverlight 应用程序可以通过很多不同的方式连接回它的服务器.包括

There a lot of different ways a Silverlight application can connect back to it’ server. Including

  • WCF - Windows Communication Foundation
  • REST (see also)
  • ADO.NET Data Services (or is this just REST?)
  • POX - Plain Old XML (E.g basic xml)
  • RIA services

对于每一个,请说明它的用途以及您何时会或不会使用它.我不是在寻找大量细节,只是在它们之间进行选择的一套经验法则".

For each of these please say what it’s for and when you would or wouldn’t use it. I am not looking for a great level of details just a set of "rules of thumb" for choosing between them.

(问题是在设计您的第一个 Silverlight 应用程序时,当您没有时间学习所有这些应用程序时,知道该使用什么.)

(The problem is when designing your first Silverlight application knowing what to use when you don’t have time to learn all of them.)

如果我在这个问题中用 WPF 替换 Silverlight 会对你的答案产生什么影响?(我假设 WPF 由于防火墙和管理策略,不能直接连接到数据库.)

推荐答案

我的两(欧元)美分:

WCF 似乎最适合可以将服务视为应用程序的业务层的情况,也就是说,当您的服务具有诸如 CalculateDiscountForClient" 之类的智能"操作时.

WCF seems best suited when the service can be viewed as the business layer of the application, that is, when your service has "intelligent" operations like "CalculateDiscountForClient".

ADO.NET 数据服务(实际上,只是一个 REST 实现)在您的应用程序基本上以数据为中心并且服务只是数据库的前端时似乎很合适.也就是说,您所有的服务方法都属于 GetCustomers、CreateInvoice 等 类型.

ADO.NET Data Services (indeed, just a REST implementation) seems appropriate when your application is basically data-centric and the service is simply a front-end for the database. That is, all your service methods are of type GetCustomers, CreateInvoice, etc.

RIA 服务 是一种非常新的技术,我还没有尝试过,但是创建 Silverlight 部分和服务非常紧密耦合的应用程序似乎很有用:您定义您在服务项目中的服务类和方法,它们会在设计时自动复制到 Silverlight 项目中.此外,您可以定义 WCF 样式的操作"方法和 ADO.NET 数据服务样式的数据"方法.看起来很有希望.

RIA services is a very new technology that I haven't experimented with yet, but it seems to be useful to create applications in which the Silverlight part and the service are very tightly coupled: you define your service classes and methods in the service project, and they are automatically replicated to the Silverlight project in design time. Also, you can define both WCF-style "action" methods and ADO.NET Data Services-style "data" methods. Looks promising.

如果您将来有可能将客户端部分从 Silverlight 更改为任何其他技术(例如 HTML+AJAX),请使用 POX,因为它是最具互操作性的选项.

Use POX if there is a chance that you change the client part from Silverlight to any other technology (for example HTML+AJAX) in the future, since it is the most interoperable option.

关于 WPF 的差异,我唯一能想到的是,对于数据访问,只要有可能,我都会使用直接 ADO.NET 数据连接(正确嵌入到数据访问层、LINQ to SQL 等)而不是ADO.NET 数据服务,因为它更加灵活.无论如何,我必须说我从未在 WPF 中开发过任何东西.

About differences for WPF, the only I can think of, is that for data access, whenever possible I would use direct ADO.NET data connections (properly embedded in a data access layer, LINQ to SQL or the like) instead of ADO.NET Data Services, since it is way more flexible. I must say anyway that I have never developed anything in WPF.

这篇关于如何为新的 Silverlight 应用程序在 WCF、REST、POX 和 RIA 服务之间进行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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