在 WCF 中实施 REST
我在 .NET 中有一个现有的 WCF,它通过 wsdl 和代理类使用。很快,就会有多个消费者,WCF 上的负载将会相当高。我被要求使用 REST 开发一个新的 WCF,这在性能方面可能是有益的。我对 REST 不太了解,因此您能否告诉我实施 RESTFUL WCF 是否会大幅提高性能?请向我提供任何实现相同功能的链接。
提前致谢, 维诺斯·卡纳
I have a existing WCF in .NET which is consumed through wsdl and proxy classes. Soon, there will be multiple consumers and the load on the WCF will be pretty high. I was asked to develop a new WCF with REST which can be beneficial interms of performance. I don't have much knowledge on REST, hence can you please let me know whether implementing a RESTFUL WCF will improve the performance drastically? Please provide me any links to implement the same.
Thanks in advance,
Vinoth Khanna.S
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以使用 WCF 数据服务轻松为您的数据提供 REST 接口。
最简单的方法是构建数据的实体框架模型,然后将该模型公开为 WCF 数据服务。然后使用 OData 协议(即 REST + AtomPub)公开所有数据。
Kiran 当然是对的,REST 本身并不能提高性能。我假设您希望 UI 直接访问 REST 服务,而不是通过包含手写方法来读取和写入数据的 Web 服务。在这种情况下,可能会有一些性能提升,但我不会指望太多。
另请参阅:
http://msdn.microsoft.com/en-us/library/ cc668794.aspx
和
http://en.wikipedia.org/wiki/WCF_Data_Services
如果您想以 JSON 形式返回结果,最简单的方法是添加 WCF 数据服务工具包:
http: //wcfdstoolkit.codeplex.com/
You can also use WCF Data Services to easily offer a REST interface to your data.
The easiest way is to build an Entity Framework model of your data and then to expose that model as a WCF Data Service. This then exposes all data using the OData protocol, which is REST + AtomPub.
And Kiran is of course right, REST by itself does not increase performance. I assume that you want your UI to access the REST service directly rather than go through a web service which contains hand-written methods to read and write data. In that case, there may be some performance gain, but I wouldn't count on it much.
See also:
http://msdn.microsoft.com/en-us/library/cc668794.aspx
and
http://en.wikipedia.org/wiki/WCF_Data_Services
If you want to return results as JSON, the easiest way to get that to work is by adding the WCF Data Services Toolkit:
http://wcfdstoolkit.codeplex.com/
据我所知,REST 并不是为了增强性能,它使您的 webmethods URL 易于访问,并使这些 URL 更具可预测性和逻辑性。我将从这个视频开始 http://channel9.msdn.com/Events/PDC/PDC08 /TL35 然后使用 WCF REST 入门套件 http://www.asp .net/downloads/starter-kits/wcf-rest
As far as I know REST is not for performance enhancement, it makes your webmethods URL accessible and make those URL's more predictable and logical. I would start with this video http://channel9.msdn.com/Events/PDC/PDC08/TL35 then with WCF REST Starter Kit http://www.asp.net/downloads/starter-kits/wcf-rest