WCF is a service layer that allows you to build applications that can communicate using a variety of communication mechanisms. With it, you can communicate using Peer to Peer, Named Pipes, Web Services and so on.

You can’t compare them because WCF is a framework for building interoperable applications. If you like, you can think of it as a SOA enabler.

WCF is a replacement for all earlier web service technologies from Microsoft. It also does a lot more than what is traditionally considered as “web services”.

The major difference is that Web Services Use XmlSerializer. But WCF Uses DataContractSerializer which is better in performance as compared to XmlSerializer.

Web services have “.asmx” extension, whereas Wcf services have “.svc” extension. The asmx page uses “WebService” directive where as the svc page uses “ServiceHost” directive.

ASP.net Web service can be hosted in IIS only.
WCF services can be hosted in IIS , WindowsActivation Services(WAS), Managed Windows services or self hosting etc.

Web services don’t support multi-threading. Whereas WCF services Support multi-threading by using ServiceBehaviour class.

WCF service is an advanced technology than Web service. Performance wise WCF is faster than web service. WCF provides more security, support various protocols & message formats. The only costly area of WCF for developer is it’s configuration settings. 

Web Service is based on SOAP and return data in XML form. It support only HTTP protocol. It is not open source but can be consumed by any client that understands xml. It can be hosted only on IIS.

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

WCF is also based on SOAP and return data in XML form. It is the evolution of the web service(ASMX) and support various protocols like TCP, HTTP, HTTPS, Named Pipes, MSMQ. The main issue with WCF is, its tedious and extensive configuration. It is not open source but can be consumed by any client that understands xml. It can be hosted with in the applicaion or on IIS or using window service.

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

public class Service : ITest
{
  public string ShowMessage(string strMsg)
  {
     return strMsg;
  }
}

Sources:

https://stackoverflow.com/questions/351334/web-service-vs-wcf-service

https://www.c-sharpcorner.com/UploadFile/00a8b7/web-service-vs-wcf-service/

Last modified: August 28, 2019

Author

Comments

Write a Reply or Comment