Thursday 28 May 2015

Difference between WCF and asp.NET Web service

Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service, following table provides detailed difference between them.


Difference between WCF and Web service

Sl. No.
Features
WCF Service
ASP.NET Web Service
1
File Format /Extension
WCF web service uses .svc as a file extension.
ASP.net web services uses .asmx as a file extension.
2
Hosting
WCF service is flexible because it can be hosted in IIS, Windows Activation Services(WAS), Managed Windows Services and It also supports Self-Hosting.
It can be hosted only IIS
3
Protocol
Supports various protocols like HTTP, HTTPS, TCP, Named Pipes and MSMQ.
Supports only HTTP, HTTPS protocols.
4
Security
Supports security, reliable messaging, transaction and AJAX and REST supports.
Support security but is less secure as compared to WCF.
5
Communication
Supports One-Way, Request-Response and Duplex service operations.
Supports One-Way and Request-Response service operations.
6
Exception
Handling
Unhandled Exceptions does not return to the client as SOAP faults. WCF supports better exception handling by using FaultContract.
Unhandled Exceptions returns to the client as SOAP faults.
7
Performance
WCF are faster than Web Services.
Web Services are slower than WCF
8
Data Serialization
Supports DataContract serializer by using System.Runtime.Serialization.
Supports XML serializer by using System.Xml.Serialization.
9
Attribute
ServiceContract and OperationContract attributes are used for defining WCF service.
WebService and WebMethod attributes are used for defining web service.
10
Encoding      
Supports XML, MTOM, Binary message encoding.
Supports XML and MTOM (Message Transmission Optimization Mechanism) message encoding.
11
Model
[OperationContract] attribute represents the method exposed to client
[WebMethod] attribute represents the method exposed to client
12
Limitations  
The DataContractSerializer translate the Hash table into the XML.
Public/Private properties/fields can be serialized.
Hash Table cannot be serialized.
Only public properties/fields can be serialized




In the above post I Explained the almost differences between WCF and asp.net Web Service. I hope its useful to you. Please comments your feedback and questions.

No comments:

Post a Comment