Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Difference between ASMX (Asp.Net classic Web Services) and WCF Services.

 ASMX VS WCF Services:

Web service:

Before WCF ASMX Web Service, or simply an Asp.Net Web Service is used to create service oriented applications.
Web Service provides its services to client applications over the web; client application makes an HTTP request to a web server to get access to its various services.

WCF Service:

Windows Communication Foundation (WCF) is a framework in Microsoft .Net for building connected, service-oriented applications.

Feature

Asp.net Web service (ASMX)

WCF Service

Hosting

Supports only IIS hosting.

You can use IIS, self hosting, Windows activation service (WAS), Windows Service.

Performance

Slower compared with WCF

Faster than asp.net web service.

It performs better over XmlSerializer since, DataContractSerializer shows which properties or fields, actually translated (or serialized) into XML.

Implementation

ASMX services are defined using two attributes namely the [WebService] and [WebMethod] in a Class.

WCF services are defined using two important attributes called the [ServiceContract] and [OperationContract], typically these attributes used with interface.

Security, Reliability and transaction support

Support security but is less secure as compared to WCF.

Supports security, reliable messaging, transaction and AJAX and REST supports.

Multithreading Support

Doesn’t support multi-threading.

Supports  by using ServiceBehaviour class.

Message exchange pattern support

 

Supports One-Way, Request-Response service operations only.

Supports One-Way, Request-Response and Duplex service operations for message exchange.

Protocols

Supports only HTTP and HTTPS.

Supports protocols like HTTP, HTTPS, TCP, Named Pipes and MSMQ.

Exception handling

Unhandled Exceptions returns to the client as SOAP faults.

Supports better exception handing by using FaultContract.

Serialization

ASMX web service would use XmlSerializer attribute for data conversion.

It is only capable of serializing public properties or members.

WCF service uses the DataContractSerializer Class to translate data into XML by using the System.Runtime.Serialization.

Hash Table

 XmlSerializer cannot translate data in an Hashtable() into XML.

DataContractSerializer can translate Hashtable() data into XML.

Easy

Easy and simple to write and configure but not dynamic, example: if changes service URL require more changes compared to WCF.

 

Easy  ,reliable and portable for new changes.

 

 

Conclusion: 

It’s better to use WCF service for new project and for existing project if possible migrate your ASMX service to WCF service.

Invalid entry,please enter valid data.

Loading