WCF vs Web Services

Most useful and most asked question in interview is WCF vs Web Services.
It could be asked in various form like Why WCF is better than Web Services

WCF and Web Services both are implementation of SOA (Service Oiented Architecture), both are SOAP based services.

WCF supports other format as well apart from SOAP but Web Service support SOAP only.

As we know there are various technology to create distributes system. Some of them are Web Service, .Net Remoting.

Sometimes there may be scenario that which technology should we use to develop distributed application. And if there is a requirement for enhancement then how difficult would it be to switch over among technologies.

WCF is the solution for all these queries. WCF is the unified technology to create distributed system which is not dependent on OS platform, Protocols to use and many more.

Lets look at differences between WCF and Web Service.

Web Service
Multiple hosting option – IIS, Self Hosting, WAS Hosting
IIS hosting is only option
HTTP, TCP, MSMQ, Named Pipe protocol supported
IIS hosting is only option
Multiple message pattern like  XML, JSON, Plain Text format supported
IIS hosting is only option
WCF supports REST Pattern
Web service does not support REST
WCF has various contract like Operation Contract, Data Contract, Message Contract, Fault Contract
Web Services has Web Methods
WCF was released in .Net framework 3.0
Web Service was released in ASP.Net 2.0
WCF uses ServiceBehavior class to support multithreading
Web Service does not support multi-threading
WCF service uses [Servicecontract], [OperationContract] attributes
Web Service uses [WebMethod] attributes

Apart from above mentioned point there are more differences like , 
To generate service model class SVCUTIL.EXE tool is used however for Web services WSDL.EXE is used.

In context of Exception handling WCF is better as they have a separate contract called Fault Contract to handle exception.



SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX

What is Cloud Computing - A guide for beginners

How to Crop and Upload image using JQuery