What are the differences between WCF and ASMX web services?
I am totally confused between WCF and ASMX web services. I have used a lot of web services in my earlier stage, and now there is this new thing introduced called WCF. I can still create WCF that function as a web service. I think there will be more stuff in WCF.
What are the differences between WCF and Web services? When should each one be used?
Keith Elder nicely compares ASMX to WCF here. Check it out.
Another comparison of ASMX and WCF can be found here - I don't 100% agree with all the points there, but it might give you an idea.
WCF is basically "ASMX on stereoids" - it can be all that ASMX could - plus a lot more!.
ASMX is:
- easy and simple to write and configure
- only available in IIS
- only callable from HTTP
WCF can be:
- hosted in IIS, a Windows Service, a Winforms application, a console app - you have total freedom
- used with HTTP (REST and SOAP), TCP/IP, MSMQ and many more protocols
In short: WCF is here to replace ASMX fully.
Check out the WCF Developer Center on MSDN.
Update: link seems to be dead - try this: What Is Windows Communication Foundation?
ASMX Web services can only be invoked by HTTP (traditional webservice with .asmx). While WCF Service or a WCF component can be invoked by any protocol (like http, tcp etc.) and any transport type.
Second, ASMX web services are not flexible. However, WCF Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends.
We develop WCF as contracts, interface, operations, and data contracts. As the developer we are more focused on the business logic services and need not worry about channel stack. WCF is a unified programming API for any kind of services so we create the service and use configuration information to set up the communication mechanism like HTTP/TCP/MSMQ etc
This is a very old question, but I do not feel that the benefits of ASMX have been fairly portrayed. While not terribly flexible, ASMX web services are very simple to use and understand. While WCF is more flexible, it is also more complex to stand up and configure.
ASMX web services are ready to stand up and add as a webservice reference as soon as you add the file. (assuming your project builds)
For the simple development workflow of
create webservice
-> run webservice
-> add webservice reference
, an ASMX webservice has very little that can go wrong, not much that you can misconfigure, and that is it's strength.
In response to those that assert that WCF replaces ASMX, I would reply that WCF would need to add a streamlined K.I.S.S. configuration mode in order to completely replace ASMX.
Example web.config for an ASMX webservice:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings />
<system.web>
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
WCF completely replaces ASMX web services. ASMX is the old way to do web services and WCF is the current way to do web services. All new SOAP web service development, on the client or the server, should be done using WCF.