WCF - Versus Web Service



There are some major differences that exist between WCF and a Web service which are listed below.

  • Attributes − WCF service is defined by ServiceContract and OperationContract attributes, whereas a web service is defined by WebService and WebMethod attributes.

  • Protocols − WCF supports a range of protocols, i.e., HTTP, Named Pipes, TCP, and MSMQ, whereas a web service only supports HTTP protocol.

  • Hosting Mechanisms − Various activation mechanisms are there for WCF hosting, i.e., IIS (Internet Information Service), WAS (Windows Activation Service), Self-hosting and Windows Service, but a web service is hosted only by IIS.

  • Services − WCF supports a robust security, trustworthy messaging, transaction and interoperability, while a web service only supports security services.

  • Serializer − WCF Supports DataContract serializer by employing System.Runtime.Serialization, whereas a web service supports XML serializer by making use of System.Xml.Serialization.

  • Tools − ServiceMetadata tool (svcutil.exe) is used for client generation for a WCF service, while WSDL.EXE tool is used for generating the same for a web service.

  • Exception Handling − In WCF, unhandled exceptions are handled in a better way by making use of FaultContract. They do not return to the client like in a web service as SOAP faults.

  • Hash Table − It is possible to serialize a Hash Table in WCF, but this is not the case in a web service.

  • Bindings − WCF supports several types of bindings like BasicHttpBinding, WSDualHttpBinding, WSHttpBinding, etc., while a web service supports only SOAP or XML.

  • Multithreading − WCF supports multithreading by using the ServiceBehavior Class, whereas this is not supported in a web service.

  • Duplex Service Operations − WCF supports duplex service operations apart from supporting one-way and request-response service operations, whereas a web service does not support duplex service operations.

Advertisements