Difference between Web Service and WCF

Web service and WCF are very important in WWW. Both tow are almost same, but have some difference. This article describes a comparison between web service and WCF . Summery of the article:

  • What is Web Service?
  • What is Windows Communication Foundation (WCF)?
  • Web Service VS WCF

What is Web Service?
Web service is a method of communication between 2 electric devices over World Wide Web. It is a software system to design communicates 2 devices through network.

Example of Web Service
At present lot of free and commercial web services are present. We can use them in our applications or project easily. Some famous and commonly used web services are: Weather service, Currency converter, Stock market reports updates, etc.
We can creates our customize Web service also. A sample Web service developed in C# is given bellow:

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

The above sample web service “TestWebService” has only one method “Test” which will return string type message.

What is Windows Communication Foundation(WCF)?
Windows Communication Foundation or WCF is a framework for building service oriented applications. By using WCF we can transfer data as asynchronous message.

Example of WCF
By using different programming language we can also creates customize WCF service. A sample C# WCF service is given bellow:

[ServiceContract]
public interface ITest
{
    [OperationContract]
    String showmessage(string msg);
}

The above WCF service has only one single method which will return string type message.

Web Service VS WCF
The difference between web service and WCF is given bellow:
Web Service 

  1. It use HTTP
  2. It is only used in web application
  3. Unhandled exceptions are return to client as SOAP fault
  4. It use XmlSerializer
  5. Accessed through HTTP
  6. It can be hosted in IIS
  7. [WebService] attribute has to be added to the class
  8. [WebMethod] attribute represents the method to client

WCF

  1. It use HTTP, TCP IP
  2. It can be used in web, desktop, Console, Mobile applications
  3. Unhandled exceptions are not return as SOAP fault. Configuration setting is provided
  4. It use DataContractSerializer which is better in Performance as compared to XmlSerializer
  5. Accessed through HTTP, TCP, MSMQ, P2P
  6. It can be hosted in IIS, windows activation service, Self-hosting, Windows service
  7. [ServiceContract] attribute has to be added to the class
  8. [OperationContract] attribute represents the method to client

That’s all about  WCF vs web service.
.

Comments

  1. Reply

Leave a Reply

Your email address will not be published. Required fields are marked *