Horizontal Menu Bar

Follow C# Tutorials

Wednesday, 18 January 2012

C#.net : Difference between Web Service and WCF

In this article we are going to see the difference between ASP.net web service and WCF service. Please see below table for difference between the two.
 
Sr. No
Features
Web Service
WCF
1
File Format/Extension
The File extension of web service is .asmx
The file extension of WCF service is .svc
2
Hosting
WebService can be hosted in IIS as well as WebService can hosted outside of IIS.
It is flexible because it can be hosted in IIS, Windows Activation Services(WAS), Managed Windows Services and Self-Hosting
3
Transport Protocols/Binding
HTTP, TCP, Custom
HTTP, WS-HTTP, TCP, Custom, Named Pipes, MSMQ, P2P(Point to Point) etc
4
Data Transformation
Done through XML serializer.
Done through DataContractSerializer
5
Serialization NameSpace
System.XML.Serialization
System.RunTime.Serialization
6
Supported Operations
One-Way and Request-Response
One-Way, Request-Response and Duplex
7
Encoding
XML1.0, MTOM (Message Transmission Optimization Mechanism), DIME (Direct Internet Message Encapsulation)
XML1.0, MTOM, Binary
8
WebMethods and DataContract
Uses WebMethods to translate .Net FW types in to XML.
  • [WebService] has to be added to the class
  • [WebMethod] attribute represents the method exposed to the client.
Uses DataContractAttributes and DataMemberAttribute to translate .Net FW types in to XML.
  • [ServiceContract] attribute has to be added to the class
  • [OperationContract] attribute represents the method exposed to the client.
9
Messaging
Uses only SOAP(Simple Object Access Protocol)
It can send/receive message in any transport protocol message format. By default it uses SOAP for communication.
10
Security
Not much secured as compared to WCF. Can’t protect the data between Server and Client. Using certificates can protect the data but it is complicated. Normally we use UserName/Password.
More secured than WebServices. WCF does not need IIS to run, it can run as a System Service on the Server, using a command ambient. WCF is a service and not a Web Service.
11
Performance
Slower than WCF
Better than WebService. The performance measures in terms of xml serialization.
12
Exception Handling
Unhandled Exceptions returns to the client as SOAP faults.
Unhandled Exceptions does not return 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.
13
Limitations
  • Hash Table cannot be serialized.
  • Only public properties/fields can be serialized
  • The DataContractSerializer translate the Hash table into the XML.
  •  Public/Private properties/fields can be serialized.

Sharing is Caring »»

Follow C# Tutorials