当&我应该在哪里使用 WCF [英] When & where I should use WCF

查看:30
本文介绍了当&我应该在哪里使用 WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了几个在线教程,这些教程涵盖了 WCF 的优势、如何构建服务/客户端等.

I have went through several online tutorials that cover the advantage of WCF, how to build the service/client, etc.

不过,我想知道一点全貌.

However, I want to know a little whole picture.

问题> 什么样的应用程序或应用程序中的哪些功能需要我使用 WCF 功能?一个具体的例子应该能更好地帮助我.

Question> What kind of application or which features in the app require me to use WCF functionality? A concrete example should help me better.

推荐答案

有几种情况需要"WCF.首先应该注意的是,require"是一个强词,虽然 WCF 是当前 .NET 中首选的通信模型,但该平台有其他方法的历史,这些方法都仍然受支持.

There are several situations that would "require" WCF. First it should be noted that "require" is a strong word, while WCF is the current preferred model for communications in .NET, the platform has a history of other methods which are all still supported.

具体示例 1:您的 Web 应用程序性能不佳,因为准备响应的一些计算工作计算成本高"并且正在消耗 CPU.您希望将费用部分移至在另一个机器上运行的服务,您可以在其中为其提供隔离资源.您创建一个 WCF 服务,该服务包装功能并将该服务部署到另一个盒子,使用代理类通过网络访问它.

Concrete Example 1: Your web app is performing poorly because some of the computational work to prepare a response is "computationally expensive" and is eating up CPU. You want to move the expense portion to a service that runs on another box where you can give it isolated resources. You create a WCF service which wraps the functionality and deploy that service to another box, using a proxy class to access it across the network.

具体示例 2:您的 Windows 应用程序需要访问位于您的用户无法穿透的防火墙后面的资源.因此,您改为选择在应用程序可以使用的 DMZ 中部署服务,该服务从 DMZ 访问受限材料并将结果返回给您的应用程序.

Concrete Example 2: Your windows application needs to access resources which are behind a firewall that your users cannot penetrate. So you instead choose to deploy a service in a DMZ which the application can use, and which from the DMZ accesses the restricted material and returns the results to your application.

WCF 是一个强大的工具,它在帮助服务开发方面做了不可思议的事情,尤其是在您开发基于 SOAP 的服务时.另一方面,有许多人认为目前编写 RESTful 服务的更简单方法是使用 ASP.NET MVC 的 WebAPI.WebAPI 最初是 WCF 团队的一个项目,但最终由于各种原因被转移到 MVC 中.如果您对 REST 感兴趣,我建议您查看 WebAPI.

WCF is a powerful tool, and does incredible things to help service development especially when you are developing SOAP based services. On the other hand, there are many who feel that currently the easier way to write RESTful services is to do so with ASP.NET MVC's WebAPI. WebAPI started as a project of the WCF Team, but was eventually moved into MVC for a variety of reasons. If you're interested in REST, I would recommend looking at WebAPI.

这篇关于当&我应该在哪里使用 WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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