WCF vs Web Service
Web services and Windows Communication Foundations (WCF) are two methods that applications communicate over a network.
More about Web Services
Web services are components of applications, which can be accessed using open protocols such as SOAP (Simple Object Access Protocol), which is an XML based language developed by the W3C, to encode and transmit data. SOAP uses XML for data descriptions and HTTP for data transfer. The main advantages delivered by these open protocols are interoperability of the services despite the differences in the platforms and the programming languages used. Web services use (WSDL) Web services Descriptions Language) to describe the services, and UDDI (Universal Description, Discovery and Integration) to list the available services. Web services do not need a web browser or HTML to operate, and may or may not contain a GUI as defined by the application. Web services can be implemented with ASP.NET.
More about Windows Communication Foundation (WCF)
Windows Communication Foundation was introduced to replace earlier web service platforms, and uses service oriented architecture in building applications. Interoperability and multiple message patterns, service metadata, data contracts, and multiple transport encodings are features of the WCF. Durable messages, AJAX and REST, and Secure Transactions features add more versatility to the platform than earlier web services.
What is the difference between Web Services and WCF?
• Web services can be hosted in IIS (Internet Information Service) or outside IIS, while WCF can be hosted in IIS, WAS (Windows Activation Service). WCF services can generally be hosted within IIS 5.1 or 6.0, the Windows Process Activation Service (WAS) that is provided as part of IIS version 7.0, and within any .NET application. To host a web service in IIS version 5.1 or 6.0, it is a must that the web services use HTTP as the communications transport protocol.
• In Web Services platform, Web Service attribute will be added to the top of the class while, in WCF, there will be a Service Contract attribute. Similarly, Web Method attribute are added on top of method of the Web service while, in WCF, Service Operation Contract will be added on the top method.
• Web services use XML 1.0, MTOM (Message Transmission Optimization Mechanism), and DIME encodings while WCF uses XML 1.0, MTOM, and Binary encodings. Both platforms support custom encoding methods.
• The web service platform supports XML Serialization while, in the WCF, service platform supports Run Time Serialization.
• WCF Services can be multi-threaded via Service Behavior class, while web services cannot be multi-threaded.
• WCF Services support different type of bindings like BasicHttpBinding, WSHttpBinding, WSDualHttpBinding while Web services only use SOAP or XML for this purpose.
• Web services are compiled into a class library assembly. A file called ‘the service file’ is provided that has the extension .asmx and contains @ WebService directive that identifies the class that contains the code for the service and the assembly in which it is located in WCF.