You have reached the blog of Keith Elder. Thank you for visiting! Feel free to click the twitter icon to the right and follow me on twitter.

WCF vs ASMX WebServices

Posted by | Posted in .Net, WCF | Posted on 17-10-2008

This question comes up a lot in conversations I have with developers. 

“Why would I want to switch to ASMX services?”

One analogy I have come up with to explain the difference between the two is an airplane analogy. 

I associate ASMX services with a Cessna 150 cockpit and I associate WCF services with a 747 Jumbo Jet cockpit. 


I’ll be honest, I’ve never flown a plane but I think I’m smart enough to crank a Cessna 150 if I had to figure it out.  The above screen shot is a real Cessna 150 cockpit.  There are a few gauges, some knobs, etc.  Really not that bad.  And I think this explains ASMX really well.  ASMX services are easy to crank and jump start.  Think about it.  We take an existing Asp.Net website and add a file called “asmx”.  Any method we attribute with [WebMethod] magically turns into a service.  Objects we pass in and pass out that have public getters and setters will be serialized into XML.

   1: [WebMethod]
   2: public string FlyToDestination(Location loc)
   3: {
   4:     // up up and away
   5: }

The barrier to cranking and getting going with an ASMX service is really simple.  And because it is simple, we’ve adopted them on a massive scale.  Let’s turn our attention to WCF.


WCF is a jack of all trades.  Think of it like a large plane that can repurposed for hauling passengers, hauling cargo, military use or whatever.  We are dealing with a plane but it is all about how that plane is configured.  Because things can be configured a lot of ways with the WCF 747 plane there are a lot more buttons in the airplane cockpit as compared to the Cessna 150.  The flip side of this is that once you understand how to configure WCF you’ve got one of the most versatile plane in the world!

From a developers stand point, the same logic or code written in an ASMX service works in WCF.  The code between the curly braces is the same.  The bottom line in either case is a method gets called and an object gets passed in (we call this a message when talking about services).  The difference in WCF is we program to a specific contract.  Here’s the same example above done in WCF.

   1: [ServiceContract]
   2: public interface IAirportService
   3: {
   4:     [OperationContract]
   5:     string FlyToDestination(Location loc);
   6: }
   8: public class AirportService : IAirportService
   9: {
  11:     public string FlyToDestination(Location loc)
  12:     {
  13:         // up up and away
  14:     }
  15: }

Instead of attributing the specific method like we do in ASMX, in WCF we attribute the Interface.  Programming to an Interface is a good thing and the reason this is done is to loosely couple the host of the service from the implementation.  Doing this opens the door for hosting WCF services not only in IIS but console apps, Winforms, WPF, etc.  Since we’ve programmed to a contract (which is just an Interface), any class that implements the Interface can be a service.  This is powerful.  This is powerful because how we expose this service is up to us (again it is all about configuration).  Because we can expose our AirportService a number of ways we can see that WCF provides developers the ability to write code once and repurpose their code as needed. 


Exposing a WCF service requires a little more training from this point forward ( just like flying a 747) because we have to understand how to configure the service.  It is this little bit of extra effort required to understand WCF configuration that stops a lot of developers from using WCF.  This is a shame because when the developer using ASMX wants to guarantee message delivery, participate in transactions, or use binary serialization instead of XML, they’ve got a lot of work ahead of them as compared to WCF.   

The moral of the story is ASMX is simple and because it is simple, it isn’t very powerful.  Take the time to learn about WCF because this is the future of the .Net platform, thus it will be time wisely spent.  If you’ve been holding back I encourage you to step out of your old ASMX habits and learn the ways of WCF. 

If you would like to dig a little deeper with WCF I encourage you to check out my “Demystifying Windows Communication Foundation” power point.  In there you’ll find a lot more details about how WCF works.


Happy messaging.

Comments (77)

First off, thanks for the great effort of a good blog post.

I’m the developer in charge of a pretty large and expansive web site dealing with lots of multipurpose applications that derive its content from the same data sets. I believe that moving to a SOA would be the best option for future development. Most of my applications work with AJAX.

What is perplexing, is that there seems to be no topical difference (besides various code and web.config enhancements) between developing an AJAX-Enabled ASMX XML Web Service and an AJAX-Enabled WCF Service.

I understand that the WCF side will send its messages back and forth in JSON, which is pretty key to good performance with JavaScript.

But it also seems like the ASMX XML-Based one does well too, data types can be serialized into JSON well via the ScriptManager.

So my question to you is: In regarding the above, why one over the other?

What are you looking for?

very welcome

give me some idea about wpf and wf .if you can.

hi keith,
i have read your article.
and it is very nice, easy to understand.
i m giving a session on wcp. and your article helps me very much.

Very welcome Pushkar, thanks for kind words.

Thanks Keith…
I really like the people who convert hard scenario in very very simple way by giving live example.
Your way of explanation is excellent.

Now i can easily travel in WCF yacht instead of ASMX boat 😉

Thanks for being my guide 🙂

Maybe I’m missing something but just add a reference to your WCF service to existing web service, shouldn’t be a big deal. Yes you can deploy web service and wcf service on the same IIS server (you don’t need WAS to do this though).

Having a web service and wcf service in the same application are no different from having more than one aspx page in a web application. I think you may be over thinking this.


Extremely Great !!

Hi Keith, I appreciate your prompt response. It is really helpful. Here I have another question. How can we consume existing web service from the WCF service. Will it be in a same fashion we consume from web page. Can we deploy web service and WCF service on the same IIS (using WAS) server on the same port.

The power point opens for me, not sure why it is not opening for you. Email me and I will send you a PDF version.

To convert existing web services you will need to:

1. Extract an interface for the service (tools like Coderush and Resharper make this really easy).
2. Apply the proper attributes you need in this interface [OperationContract] and so on.
3. Implement that interface on your existing class file
4. Expose the service with the binding you want to use.

Tip: Put your interfaces in one DLL so they can be easily re-used.

This is a good question, I may do an article on this later on.


Hi, It was a great article to kick start WCF understanding. I am using the web services for a long time and now want to switch into WCF. Can someone tell me how to convert existing web service into WCF service and what about the security.

Thanks for the advice it concurs with others. I will build this simple little project I need quickly in webservices and leave WFC for the right day.


Yes, not even close.

Great article. Thanks to all buddies who shared their knowledge.

I have one question in my mind for a long time. Is WCF provides more secured services as compared to ASMX.


Really nice work. Now i can also differentiate them properly…. Thanx man

Hi, when I try and download the ppt file it doesn’t open (Office 2003, with 2007 Compatibility pack installed). If I rename the extension to .zip I can see there are contents (i.e. it is a pptx file) but it still cannot be loaded. Could you possibly upload the file as a zip – I think it is getting mangled in transit. Many thanks!

Hhuummm Gr8…I must say Very good comparison.

Well actually I was backing when hearding WCF because I didn’t know what exactly it was and capable of. Now I know there is something great coming out actually already came out.

Thanks for the article. From now on I am on learning WCF at MSDN.

Easy. The comparison is, there isn’t a comparison.

Really the best thing to do when it comes to WCF and ASMX is just look at this chart which outlines the bindings of WCF. Understanding and configuring bindings is what makes WCF more complex to learn (just like in a jet cockpit, this is where all the buttons and switches lie).

For a comparison, look at the “basicBinding”. This is essentially the ASMX equiv in WCF.

Then look at the wsHttpBinding and the tons of others and the features they offer.

So really when you look at it from that angle, there really isn’t a comparison.

Here is the link:


Well, first of all good blog and nice comparison. no doubt WCF looks Future technology, but it’s complex and need more time to grasp and then impliment. i am still not sure if i spend few weeks on study and then impliment WCF or hit the ground with ASMX web service and in 2-3 weeks finish the project.

can you through light on security of WCF. how good is? if possible comparison.



Forcing admins to edit XML isn’t a WCF problem, it’s a software design and application development problem.

AGREE!!! All web app’s that I build include an easy to use admin/config section so even the most novice web admin can follow a set of simple instructions to get the app delivered and running. The small amount of time you devote to building this config portion of your app will pay off each time you drop it into the next application. Need more info/idea’s? ask away…..

Cool article.


Nice comments on WCF. I think we can share more and more about the architecture and implementation about WCF. I am started the experiment. Lets see. I will post my doubts as the implementation progress. Its a good article

No promises I’ll get to it quickly but send it over, my email is on the about page. May make for a good blog post.


dont hurt to ask….. would you mind if i send you my solution, and tell me what i am doing wrong?


There is a video of a prensentation I did of that deck this past week that you can watch (even better than getting just the deck) that I will share where I do this presentation. I’ll update this once it is ready.


You definitely have something wrong as what you are implying flies in the face of computer science. Binary is just faster. I don’t have a link to the sample app because I’ll need to write up a whole article on just how to configure it. Which I plan on doing one day.

Can’t read the ppt in any way

Thanks for the response, nice to know someone actually monitors their blog 😉

I have also built an app to compare asmx and tcp performance, and to be honest (also i could be doing something wrong), i do see difference when sending a large amount of data, but not much difference when sending a smaller ones, is that expected?

Would love to see your benchmark, you have a link to the sample app?


There’s something other than that to consider and that is speed or performance.

If you are going from .Net to .Net, meaning your server is .Net and all of the clients hitting your service is .Net, then you can or will get a tremendous speed increase using WCF over ASMX.

I have a sample app that I built that benchmarks the various bindings as well as asmx. A WCF service using netTcpBinding (which is a binary binding) processed 100 messages in 40 milliseconds. The exact same call made with ASMX was 323 milliseconds.

Even if you use the basicHttpBinding which is essentially what an ASMX service is you will still see a performance increase merely because WCF’s serialization is faster.

thanks for the article. Agree wcf is lot more complex compared to asmx. But the fact that asmx is being phased out by wcf does not leave us any choice but to learn wcf, does it?

One question i have tho, yes understood wcf is more feature rich than asmx. but in terms of interoperability between platforms, and if our applications do not need all the additional features such as security, i can safely assume, asmx offers the same interoperability as wcf, yes?

20% isn’t even close with the numbers you can achieve with WCF compared to ASMX depending on the situation.

I have a blog post I’m working on that will show how things compare. Stay tuned.

At your company you may be running into the built-in throttling with WCF. It is out of the box tuned down for DOS attacks. You have to chose a fair balance between what you want to allow.

Make no bones about it. It is more complex because, well IT DOES MORE. Having a single programming model is a huge will in my book. It is something we need and we’re just seeing the surface scratched with WCF.

WCF has some interesting ideas, but its layers of complexity pretty much cause it to screw the pooch, both in terms of programability and performance. All those layers of abstraction have a significant cost. At launch MS has was only able to claim about a 20% performance edge over standard web services, which begs the question of “why bother”. In our experience at _major_internet_company_ WCF falls apart at any scale above small enterprise (~2000 users). If you’re in the workgroup-to-enterprise pocket, maybe it offers something truly useful beyond what one could roll themselves, but I haven’t found it.


The architecture of WCF vs .Net remoting couldn’t be more different. That’s just one of the things WCF unifies as the communication platform.

You mean that WCF will replace .net remoting , i can see WCF architecture is pretty same as .net remoting.

I don’t get it, why are you two so bent out of shape of not supporting WSDL 2.0? That spec was just released in middle or late of 2007 and the development of WCF was already WELL underway.

I’m sure the teams are looking at the spec and figuring out what to do with it.

There’s a lot of platforms that don’t even support nested schemas like the WSDL’s generated for WCF out of the box.

I don’t see this as a big deal. Get over it and move on.

Yah Lacking support of WSDL 2.0 is a very disgusting thing.Other wise it’s a great innovation of integrating nearly all type of communication

Microsoft and WCF really sucks !!!, it does not provide WSDL 2.0 support nor 100% xml-schema compliance nor fully WSDL contract first design.

The boeing 747 has 38 years of changes over it’s body. WCF not so many.

I guess the idea of this post of “hey! do you trust in a boeing 747? trust WCF too” tries to generate a bit of missunderstanding.

WCF is new, and still lacks “things”. But it will depend on your project. You’ll be surprised about some common functionality missing on WCF.

Choose your tool carefully 🙂

Our WCF application does not use any webconfig at all. Everything is done programmatically, and user friendly UI’s in the product allow relevant knobs to be turned.

Forcing admins to edit XML isn’t a WCF problem, it’s a software design and application development problem.

Nevermind WCF and ASMX….. whose flying the plane?!?!?!!!

Microsoft is now making things more complex. Consider the case of normal web admins. Can they configure the webconfig files, since WCF adds lots of configurations in webconfig file.

However technology is good I also view an article related to the performance of WCF and ASMX. Check out it:


Awesome..indeed 🙂

One counter argument to WCF is that configuration of WCF by the web administrator is not a trivial excercise. More and more cr@p is getting shoved into web.config with each new .Net release, and what used to be manageable by your typical web admin is quickly becoming something that is only understood by web developers. This is not a good thing.

If you want to get into WCF and create a service that is just about as simple as an ASMX service, create a new “Silverlight-Enabled WCF Service” (assuming you have the SL tools installed). That creates a WCF service that is SOAP 1.1, does not use a separate interface definition, and supports serializing additional types like, say, Uri, that ASMX does not. It sets up the config file for you as well.

You get Cesna controls on top of your 747 🙂


Another thing that is great about WCF is that its architecture forces you into writing more cleanly separated code. Even with ASMX web services good developers would separate their logic into an assembly using the service as just a communication mechanism.

WCF makes this easier to achieve by enforcing it in the architecture. You can easily use your WCF service classes just like a regular library. Doing so allows for better code reuse and the fact that your services are exposed over the network via[insert method here] it just a configuration detail.

Awesome comparison between the two!

Write a comment