Differences Between WCF and ASP.NET Web Services
In an interview it is a very common question “what is the basic difference between WCF and webservice?” or “Why to use WCF over ASP.NET Web service?”.
In below table differences between WCF Services and ASP.NET Web Services is explained:
|WCF||ASP.NET Web Secvice|
|[ServiceContract] and [OperationContract] attribute defines webservice and methods.|
|[WebService] and [WebMethod] attribute defines asp.net web service and methods.|
|Hosted in IIS, Windows Activation Service (WAS), Self-Hosting, Windows Service.||Hosted in IIS.|
|Accessed through HTTP, TCP, MSMQ, P2P, Named Pipes||Accessed through HTTP.|
|It Supports security, reliable messaging, transactions, durable messages, service orientation,|
interoperability, service metadata, AJAX and REST Support, extensiblity.
|It Supports security services.|
|it uses Service Metadata tool (svcutil.exe) to generate client for the service.||It Uses command-line tool WSDL.exe to generate the client for the service.|
|Unhandled exceptions are not returned to clients as SOAP faults.|
A configuration setting is provided to have the unhandled exceptions returned to clients for the purpose of debugging.
|Unhandled exceptions are returned to clients as SOAP faults.|
|The generated WSDL can be customized by using ServiceMetadataBehavior class.||The generated WSDL can be customized by using ServiceDescriptionFromatExtension class.|
|System.RunTime.Serialization is supported.||System.RunTime.Serialization is supported.|
|It can be Multi-Threaded via ServiceBehavior class.||Can not be Multi-Threaded|
|Supports different type of bindings like BasicHTTPBinding, WSHTTPBinding, WSDualHTTPBinding etc.||Can only use SOAP or XML for this.|