Open In App

Difference between WCF and Web Service

Last Updated : 28 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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 is 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.  

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads