tags:

views:

1500

answers:

3

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!

+2  A: 

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.

Yossi Dahan
+4  A: 

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)

bh213
+8  A: 

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.

James Bender
In WCF, DataContractSerializer can access non public member so it requires full trust while XML Serializer(in web services) doesn't. This should be used with care as fully trusted code accesses all resources on your machine.
Adeel