Monday, 15 April 2013

What is the difference between Webservice and WCF in .NET?

What is the difference between Webservice and WCF in .NET?
 
If you are going for .NET technical interview and have mentioned WCF in your CV/Resume, I am 100% sure that you will be asked the question "What is the difference between webservice and WCF"? So be ready with this technical interview question.
 
WCF is a .NET 3.5 technology introduced by Microsoft. It unifies all communication options available in earlier versions of .NET framework. You can make a WCF application that would act exactly the same as a WebService, but it will be easier to implement and manage.
 
Here is the list of differences between Webservice and WCF
 
1. WCF has been designed by Microsoft from the scratch to comply with SOA (Service Oriented Architecutre). while Webservices do not comply with the Service Oriented Architecutre.
 
2. Webservice can only be hosted on IIS while WCF can be hosted on any server like WAS (Windows Activation Service), Self-hosting, Managed Windows Service.
 
3. WCF can be accessed via various protocols like SOAP over HTTP, Binary over TCP, Named Pipes, P2P, MSMQ etc. while webservices can only be accessed via HTTP. 
 
4. [WebService] attribute has to be added to the class and [WebMethod] attribute to be added to the method exposed to client in case of webservice while [ServiceContraact] attribute is added to the class and [OperationContract] attribute is added to the method exposed to client in case of WCF. 
 
5. System.Xml.Serialization namespace is used for serialization in webservice while System.Runtime.Serialization namespace is used for serialization in case of WCF.
 
6. WCF can be multithreaded via ServiceBehavior class while webservices cannot be multithreaded.

No comments:

Post a Comment