what is difference with WCF and other web services?

我对WCF和其他Web服务(如asp.net ASMX,.net Remoting)感到困惑,有谁可以告诉我与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 (ie 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 (ie 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.


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 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.

链接地址: http://www.djcxy.com/p/71284.html

上一篇: 将ASMX转换为WCF Web服务需要多少努力?

下一篇: 与WCF和其他Web服务有什么不同?