Differences between Web Services and WCF in ASP.NET

This is one of the good WCF interview Question

1. File Format or Extension
Web Service:Web service file extension is .asmx
WCF: WCF service file extension is .svc

2. Hosting 
Web Service:WebService can host in IIS and outside of IIS also. Please refer this Microsoft article for more details.
WCF: WCF service can host in self hosting, IIS, Windows Activation Services(WAS) and Managed Windows Services.

3. Transport Protocols or Binding 
Web Service:HTTP, TCP, Custom
WCF: HTTP, WS-HTTP, TCP, Custom, Named Pipes, MSMQ, P2P(Point to Point) etc

4. Data Transformation 
Web Service:XML serializer
WCF: DataContractSerializer

5. Serialization NameSpace 
Web Service:System.XML.Serialization
WCF: System.RunTime.Serialization

6. WebMethods and DataContract 
Web Service: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.
WCF: 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.

7. Security 
Web Service: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.
WCF: 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.

8. Encoding techniques 
Web Service:XML1.0, MTOM (Message Transmission Optimization Mechanism), DIME (Direct Internet Message Encapsulation)
WCF: XML1.0, MTOM, Binary

9. Supported Operations 
Web Service:One-Way and Request-Response
WCF: One-Way, Request-Response and Duplex

10. Limitations 
Web Service:
  • 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.

11. Messaging 
Web Service:Uses only SOAP(Simple Object Access Protocol)
WCF: It can send/receive message in any transport protocol message format. By default it uses SOAP for communication.

12. Exception Handling 
Web Service:Unhandled Exceptions returns to the client as SOAP faults.
WCF: 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. Performance 
Web Service:Slower than WCF. The performance measures in terms of xml serialization.
WCF: Better than WebService.

Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar