Comparing ASMX and WCF

Tagged: wcf service asp-net handlers best practices

I’ve been working with both ASMX and WCF web services for about 2 years now. And although according to Microsoft, WCF is designed to replace all previous communication technologies, but some people are still creating web services using ASMX including me.

It’s known that WCF will provide the functionality of WS-* standards in an easier way than previously was possible. But as these standards were not supported on most development platforms and provide features that are not needed by default in most of the web services. Most of the services are using SOAP basic profile which can be implemented using both WCF or plain old ASMX.

Here is a comparison between using both technologies to create a web service with basic profile binding:

Feature ASMX WCF Comments
Easy to learn and code Both have similar attributes that are added to service and data classes
Easy to configure WCF adds a hell of configuration keys with different options that mostly are not useful
Easy to deploy With the complex configurations and options of WCF, its relatively hard process to deploy a WCF service
Easy to browse and test ASMX services provide a page to easily browse the services operations and enable users to test these operations from the browser.
It also shows a full sample of the SOAP HTTP message to call the service simplifying the life for developers who are trying to send these requests manually (mostly because their development platform doesn’t support it)
Easy to debug errors Using WCF introduces a set of ambiguous exceptions that maximize the complexity of working with the technology.
Compatibility with older .NET Frameworks Trying to call a WCF service from .NET Framework 1.1 or 2.0 is a bad scenario
ASP.NET Context In WCF this is off by default, so you have to add some compatibility configurations to be able to access the ASP.NET context which contains: Cache, Session, Cookies, Request headers specially host address
Support for JSON data format Both added JSON support in .NET 3.5 to support calling the service from javascript
Support for WS-* standards A plus for WCF where it will be a very big hassle to work with WS-* with ASMX
Support for binary data format Although it’s not recommended but it could be useful for bandwidth to use binary instead of XML with WCF
Support for REST Don’t confuse REST with JSON as REST is the way HTTP requests are sent with parameters in URLs and using multiple HTTP actions instead of just GET.

I’m not sure that ASMX doesn’t support REST so if anyone has more information please post your comments.
Intercepting messages across the service/client WCF support creating code that run in certain events to intercept messages and process them across all service operations.

This is not available in ASMX and could be useful in certain complex scenarios like doing custom authentication, authorization, logging and routing techniques.
Customizing client side functions WCF enables you to take the service interface through a class library and use it to call the service without adding a service reference (using a dynamic channel factory). This allows using the same data classes in both the service and client, making it possible to include functionality in these classes (like caching, validation or auto calculated properties) that can be used on the client side.

This can’t be done using ASMX as it can only be called from the web reference which creates a copy of the data classes (taking only fields that are transferred on wires) without any functionality that was on the service classes.

After this comparison, my recommendation is the following: if you are using SOAP Basic Profile which is the most probable, always use ASMX for it’s simplicity and ease of use unless you need a feature that only exists in WCF. This will save you a lot of trouble.

Note: Another tip, if you are already using WCF with the default binding wsHttpBinding and you are not making use of any special feature of this binding (using only features like old ASMX). It’s better to change this binding to httpBasicProfile as this will greatly enhance the performance of your service.

In later posts, I’ll try to explain some of the above topics with how to and code samples.

13 Comments

  • trener personalny opole said

    This is something that should be discussed during the
    first session with your trainer as well. If you spend your day
    at a desk, take ten minutes out of every 2 hours to get up, get moving and
    get closer to a body you can be proud of.
    An undergraduate degree makes you eligible
    to apply for an athletic trainer job.

  • Aleisha said

    I'm curious to find out what blog platform
    you happen to be working with? I'm experiencing some minor security issues with
    my latest blog and I'd like to find something more secure.
    Do you have any suggestions?

  • New Balance 595 said

    New Balance 595 New Balance MS77 ocVzE Quando delicatamente
    spremuto, poche gocce dal substrato. ESEMPIO: Dive spugna familiare in acqua per saturare completamente.
    New Balance 991 New Balance 373 tosmy Rimanere qui per cinque respiri profondi, sollevare attivamente i fianchi
    più in alto possibile, coinvolgere gli addominali e cercare di non stringere i glutei.
    Quando si è pronti per uscirne, sollevare la gamba destra da
    terra e ruotare il busto così si pianta il palmo della
    mano destra e tornare Down Dog. New Balance 373 New Balance 501 WRTOr L'incidente ha avuto inizio
    il 28 Marzo 1979 con l'errore nel sistema secondario non nucleare, seguito da un pilota aperto fisso Valvola regolatrice (Porva) nel sistema primario,
    che ha permesso grandi quantità di raffreddamento del reattore di fuggire.

    I guasti meccanici sono stati aggravati dal fallimento iniziale dei
    gestori degli impianti di riconoscere la situazione come una perdita
    di liquido refrigerante incidente a causa di una formazione inadeguata e ambigui indicatori sala di controllo..
    New Balance 420 New Balance 420 Xkjzm Ho appena messo l'ultima scatola di Ashley Graham scarpe estive nel retro di un camion Penske (Budget
    effing fa schifo, BTW), e lei e la signora Graham ora è da qualche parte
    tra 206 e la sua nuova casa a San Francisco. Negli ultimi 7 anni, Graham ha lavorato l'interruttore stampa locale
    oltre a LiveNation, organizzando tutte le cose mezzi relativi a uno
    dei più grandi promotori della regione. New Balance 373 New Balance 595 AxwEy Relax Pool Party potrebbe trasformarsi in un fish98 piscina.

    Concorso di bellezza Prison99.

    New Balance 996 New Balance 1500 HNZTj E io farò mai un mixtape insieme.

    Oh, per essere una mosca sul recinto tutti!
    Fascia di età individuale non è sicuramente per chi farlo,
    ed è apparso anche più volte. New Balance 1500 New Balance 999 jDXmz Tutto questo
    lavoro e l'innovazione, quando è stata l'età d'oro dei quali concentrati sulla crescita,
    l'aspirazione, e lo shopping. Segmento di clientela è stata estesa agli uomini che stavano
    ormai diventando stile consapevole troppo. New Balance
    751 New Balance 751 wiXoT Finché nessuno ti dice come vestirsi
    si può indossare quello che vogliono. Una volta ho
    avuto una ragazza che piaceva quello che indossavo quando abbiamo incontriamo l'altro e poi deciso che
    il mio guardaroba non è appropriata quando il rapporto era
    stabilito dentro Inutile dire che non è stato in giro
    per molto tempo..

  • music volume said

    Thanks , I've recewntly ƅеen searching fօr info aрproximately thiѕ
    subject for а lߋng time andd yurs is tɦe ƅеst I've discovered till noա.
    But, ѡhat іn regaгds too tɦe bоttom line?

    Arе yoս sure concerning the supply?

  • received drug addiction said

    Hello! Quick question that's entirely off topic. Do
    you know how to make your site mobile friendly?

    My web site looks weird when viewing from my iphone.

    I'm trying to find a template or plugin that might be able to
    correct this problem. If you have any recommendations, please share.
    Thank you!

  • louis vuitton handbags outlet authentic said

    http://hh.heathenhideout.com/uk/sitemap-1.xml Naрles Police reports show the thefts occuггed
    from Јan. 1, 2006, to Feb. 1, 2007. Thе investigation was prompted by an alert from Ѕtrohmeyer's credit card cоmpany.

  • kredyt bez zaswiadczen said

    Hey very nice blog!! Man .. Excellent .. Superb .. I will bookmark your site and take the feeds additionally?
    I am glad to find a lot of helpful information right here within the publish,
    we need develop extra techniques in this regard, thank you for
    sharing. . . . . .

  • Aracelis said

    I read a lot of interesting content here. Probably you spend
    a lot of time writing, i know how to save you a lot of work, there is an online tool that creates unique, SEO friendly posts in minutes,
    just type in google - laranitas free content source

Add a Comment