Loading

Windows Communication Foundation (WCF)

Major differences that exist between WCF and a Web service.. The Complete Windows Communication Foundation (WCF) Developer Course 2023 [Videos].

WCF (Windows Communication Foundation): WCF, as the name suggests, is a unified .NET framework that is used to develop service-oriented applications. It allows you to develop applications that can communicate using different communication mechanisms.

It is founded for other Microsoft Distributed Technologies and considered the future of distributed computing.  Because of its flexibility, it makes the development of endpoints much easier. It supports various programming languages and platforms. It is SOAP-based and returns data in XML form. It can be hosted in different scenarios, and such scenarios include various services such as WAS, IIS, Managed Windows, etc. The following code will be used to build a service in WCF:  

[ServiceContract]  
public interface ITest  
{    
 [OperationContract]    
 string ShowMessage(string strMsg);  
}  
public class Service: ITest  
{    
 public string ShowMessage(string strMsg)    

Web Service: Web Service, as the name suggests, is a client-server application that allows communication between client and server applications. It is basically a software module specially designed to execute a certain set of tasks. This service is specially used to make application platforms and technology independent. There are two types of web services include the SOAP web services and RESTful web services.  Following code will be used to build a service in Web service: 

[WebService]  
public class Service: System.Web.Services.WebService  
{  
 [WebMethod]  
 public string Test(string strMsg)    
    {    return strMsg; 
    }  
}  

WCF vs Web Service  

WCF  

Web Service 

It is used for sending data asynchronous messages from one service endpoint to another.  It is used to exchanging data between applications or systems.  
Protocols used in this channel include HTTP, TCP, MSMQ, named Pipers.Protocols used in the channel include HTTP and JMS.  
It is designed to offer a manageable approach for creating Web Services and Web service clients.  It is designed to perform or execute a certain set of tasks. 
It provides a runtime environment for service allowing you to expose CLR types as Services and to use other services as CLR types. Service-oriented allows you to expose the functionality of existing code over the network so that other applications can consume the functionality of your program.  
Its features include service-oriented, reliable, and queued messages, multiple transports, and encoding that support multiple message patterns, interoperability, etc.  Its features include loosely coupled, supports document exchange, supports RCF (Remote Procedure Calls), ability to be Synchronous or Asynchronous, language-independent and interoperable, etc.  
It is more flexible as this service can be hosted in different types of applications.  It is less flexible as it can only be accessed over HTTP.  
Such service can be hosted on IIS, WAS, and Windows services.  Such a service can only be hosted on IIS server.  
It uses DataContractSerializer.  It uses XmlSerializer.  
Its extension is “.svc”.  Its extension is “.asmx”. 
It is more reliable, fast, and robust as compared to web services, and therefore it considered good for developing real-time applications.  It is not reliable and slow as compared to WCF.  
It supports duplex operations and multi-threading.  It does not support duplex operations and multi-threading.  
It also supports robust security, trustworthy messaging, transaction.It only supports security services.  

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.

See All

Comments (738 Comments)

Submit Your Comment

See All Posts

Related Posts

Windows Communication Foundation (WCF) / Blog

What is WCF?

WCF stands for Windows Communication Foundation. It is basically used to create a distributed and interoperable Application. WCF Applications came into the picture in .Net 3.0 Framework. This is a framework, which is used for creating Service oriented Applications. You can send the data asynchronously from one end point to another. I think you all know about Web Service and are thinking, if we already have Web Services and accessing on a remote basis then why did WCF come into picture?
22-Apr-2022 /50 /738

Windows Communication Foundation (WCF) / Blog

Major differences that exist between WCF and a Web service.

WCF (Windows Communication Foundation): WCF, as the name suggests, is a unified .NET framework that is used to develop service-oriented applications. It allows you to develop applications that can communicate using different communication mechanisms.
22-Apr-2022 /50 /738

Windows Communication Foundation (WCF) / Blog

Difference between WCF and Web API.

WCF is used to create a distributed and interoperable Applications. It provides a framework which is used for building service-oriented-connected applications for the transmission of the data as an asynchronous, from one service-point to other service-point. Previously known as Indigo and is a framework for building, configuring, and deploying network-distributed services.
22-Apr-2022 /50 /738