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!
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)
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With