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.

WCF
Web Services
Multiple hosting option – IIS, Self Hosting, WAS Hosting
IIS hosting is only option
HTTP, TCP, MSMQ, Named Pipe protocol supported
Only HTTP protocol supported
Multiple message pattern like  XML, JSON, Plain Text format supported
XML is the only option to exchange message
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


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.

Popular posts from this blog

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

Calling ASP.Net WebMethod using jQuery AJAX