Aug 08

Differences Between WCF and ASP.NET Web Services

WCF

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:

 

 

WCFASP.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 PipesAccessed 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.

  • Better performance.
  • DataContractAttribute and DataMemberAttribute can be added to .NET framework types to indicate
  • that instances of the type are to be serilized into XML, and which particular fields or properties
  • of the type are to be serialized.
  • Classes that implement the IDictionary interface can be serialized.
  • Hash table can be serialized
System.RunTime.Serialization is supported.

  • Worse performance.
  • Only public fields and properties of .NET types can be translated into XML.
  • Only the classes which implement IEnumerable and ICollection interface can be serialized.
  • Hash table can not be serialized.
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.

Permanent link to this article: http://zappmania.in/2013/08/08/differences-between-wcf-and-asp-net-web-services.htm

Leave a Reply

Your email address will not be published.