WCF 和其他 Web 服务有什么区别?

发布于 2024-07-11 09:41:07 字数 118 浏览 4 评论 0原文

我对 WCF 和其他 Web 服务(例如 asp.net ASMX、.net Remoting)感到困惑,谁能告诉我 WCF 和其他 Web 服务有什么区别以及我什么时候应该使用它,谢谢!

I'm confused with WCF and other web services (such as asp.net ASMX,.net Remoting),can anybody tell me what is difference with WCF and the others and when should I use it, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鹊巢 2024-07-18 09:41:07

WCF 是一个通信堆栈,允许通过 HTTP(如 ASMX)和 TCP(如 Remoting)以及命名管道(实际上是机器内跨进程调用)、MSMQ 和 .NET 3.5 REST 公开服务。

它允许这样做,因为它将服务的通信部分与业务逻辑分离。 您需要做的就是使用适当的契约属性(分别是[SeriviceContract]、[OperationContract] 和[DataContract])来装饰您的服务类、方法和DTO。

这样做的好处是能够编写一次服务,并允许多次编写服务。不同类型的客户端可以使用相同的服务(即Java客户端可以使用HTTP,.NET客户端可以使用TCP,传统客户端可以使用MSMQ等)。

WCF 仍然允许您使用每种传输的所有功能,包括安全性、事务、可靠的消息传递等,但您需要谨慎使用。 并非所有功能都适用于所有传输,您需要进行相应的设计。 WCF 允许您在合同中指定需要哪些功能。 这可以防止有人尝试以不支持所需功能集的方式公开您的服务(即,如果您的服务需要事务,WCF 运行时将不允许通过基本 HTTP 端点访问该服务)。

WCF 还可以通过自定义行为(影响 WCF 运行时的工作方式)和自定义通道(控制 WCF 服务与外部世界的通信方式)进行扩展。

与 ASMX 相比,WCF 有一点学习曲线,但好处绝对超过重量这个学习曲线。

希望有帮助。

WCF is a communication stack that allows services to be exposed over HTTP (like ASMX) and TCP (like Remoting) as well as Named Pipes (which is really an intra-machine cross process call), MSMQ and with .NET 3.5 REST.

It allows this because it's decoupled the communcation parts of the service away from the business logic. All you need to do is decorate your service classes, methods and DTO's with the appropriate contract attribute ([SeriviceContract], [OperationContract] and [DataContract] respectivly.)

This had the benefit of being able to write a service once, and allowing many different kinds of clients to consume the same service (i.e. Java clients can use HTTP, .NET clients can use TCP, legacy can use MSMQ, etc.).

WCF will still allow you do use all the features of each transport, including security, transactions, reliable messaging, etc., but you need to use some care. Not all features work on all transports, and you need to design accordingly. WCF allows you to specify in your contract which features are required. This prevents somone from trying to expose your service in a way that does not support the required feature set (i.e. if your service requires transactions, the WCF runtime will not allow the service to be accessed via a basic HTTP endpoint).

WCF is also extensible via custom behaviors (which influence how the WCF runtime works) and custom channels (which control how WCF services communicate with the outside world.)

WCF has a bit of a learning curve compared to ASMX, but the benefits ABSOLUTLY out weight this learning curve.

Hope that helps.

温暖的光 2024-07-18 09:41:07

WCF 是通信库,它是 .NET 远程处理和“旧”ASMX Web 服务的超集,也是这两个库的后继者。

WCF Web 服务对 WS-* 标准有更好的支持,并且互操作性问题较少。

基本上,您应该使用 WCF,因为 .net Remoting 和 ASMX 可能被认为是遗留的(并且,如果我没记错的话,一些 .NET 远程处理错误仅在 WCF 中修复,而从未在 .NET 远程处理本身中修复)

WCF is communication library that is superset of both .NET remoting and "old" ASMX web service and successor of both of these libraries.

WCF web services have much better support for WS-* standards and have less problems with interoperability.

Basically, you should use WCF since .net Remoting and ASMX might be considered legecy (and, if I recall correctly, some .NET remoting bugs were only fixed in WCF and never in .NET remoting itself)

逆光飞翔i 2024-07-18 09:41:07

我认为可以公平地说 WCF 取代了 ASMX 和远程处理。
您可以使用 ASMX 和远程处理以及 WCF 实现您能实现的一切,但您拥有更多的功能,并且通常对正在发生的事情有更多的控制。

所以我相信,如果可以的话,您应该使用 WCF。

I think it is fair to say that WCF replaces ASMX and remoting.
You can achieve everything you could with ASMX and remoting and more with WCF, but you have a lot more capabilities and generally a lot more control over what's going on.

So I believe that, if you can, you should be using WCF.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文