What is the difference between webservice and wcf service? is a very common question in almost every interviews. This is one of the most important topic because programmer should know when to use asp.net web service and when to use wcf service. We should know what is webservice and what is wcf? In other article i have already explained about web service and what is wcf service. The summary of the two is given below.
What is Webservice?
According to web definition from WIKI –
“…A web service is a method of communication between two electronic devices over World Wide Web. It is a software function provided at a network address over the web with the service always on as in the concept of utility computing.”
Web service is a mechanism that provides data as a service/response over the http protocol on request of some other programs.
What is WCF service?
Windows Communication Foundation (WCF) is a often use to develope and deploy network distributed services based on the principles of Service Oriented Architecture (SOA). The fundamental characteristic of WCF is Interoperability. This gives you more manageable approach to create and consume web services.
|C#.Net – Web Service Vs WCF service|
In this c# tutorial we are going to see the difference between ASP.net web service and WCF service. The table below shows the difference between webservice and wcf. By the end of this article i believe you will completely familier with webservice vs wcf service.
Difference between Webservice and WCF service
|Sr. No||Features||ASP.net Web Service||WCF Service|
|1||File Format/Extension||ASP.net web services uses .asmx as a file extension.||WCF web service uses .svc as a file extension.|
|2||Hosting||ASP.net Web service can be hosted in IIS. As well as ASP.net WebService can be hosted outside of IIS like ASP.net web service can be hosted in a Windows Service.||WCF service is flexible because it can be hosted in IIS, Windows Activation Services(WAS), Managed Windows Services and It also supports Self-Hosting.|
|3||Transport Protocols/Binding||ASP.net Web service supports HTTP & TCP protocols along with custom binding.||WCF service supports HTTP, WS-HTTP, TCP, Custom, Named Pipes, MSMQ & P2P(Point to Point) etc.|
|4||Data Transformation||It uses XML serializer for Data Transformation.||WCF service uses DataContractSerializer for Data Transformation.|
|6||Supported Operations||The supported operations are only One-Way and Request-Response type.||The supported operations includes One-Way, Request-Response and Duplex.|
|7||Encoding||It uses following encoding mechanisms –
XML1.0, MTOM (Message Transmission Optimization Mechanism), DIME (Direct Internet Message Encapsulation)
|It uses following encoding mechanisms –
XML1.0, MTOM, Binary
|8||WebMethods and DataContract||Uses WebMethods to translate .Net FW types in to XML.
||Uses DataContractAttributes and DataMemberAttribute to translate .Net FW types in to XML.
|9||Messaging||Asp.Net web service supports only SOAP(Simple Object Access Protocol) as messaging service.||WCF service can send/receive message through any transport protocol message format. However, by default it uses SOAP for communication.|
|10||Security||This is not much secured as compared to WCF. It is less secured to protect data between Server and Client. Certificates can protect the data but it is very complicated to use Certificates. For security, normally we use UserName/Password.||As compared to ASP.net web service, WCF services are more secured. WCF does not need IIS to run, it can run as a System Service on the Server, using a command ambient. We can say that WCF is a service and not a Web Service.|
|11||Performance||Performance wise web services are slower than WCF service.||WCF services are than WebService. The performance measures in terms of xml serialization.|
|12||Exception Handling||This returns all unhandled exceptions to the client as SOAP faults.||WCF does not returns unhandled Exceptions to the client as SOAP faults. A configuration setting is provided to have the unhandled exceptions returned to the Client for the purpose of debugging.|
I hope you enjoyed the article that explains the difference between webservice and wcf. If you find this article helpful, then could you please share the article on your social media?
Following articles might be of your interest…
- How to consume WCF service.
- How to consume a WCF service hosted in Window Services.
- How to consume a WCF service in WPF application.
- How to consume wcf service in Asp.net Application.
- How to enable WCF Tracing and MessageLogging.
- More WCF articles…