R – What to choose? ASMX web service or WCF in .net 3.5

.net-3.5asmxnetwcfweb services

The current project i am working on is extensively using web services and is made in .net 3.5. Now as we are going for implementation of second phase we are confused if we should either use WCF or web service as done previously ? Further is there anything new that can be useful and is coming up with .net 4.0 regarding web services or WCF.

Best Answer

We just finished a brand new project using WCF instead of ASMX Web Services for the first time. We are VERY happy with the results, but do know that there was a steep learning curve. Even so, we are extremely pleased with the overall results and know that this is the basis for everything Microsoft is doing going forward and it has been totally worth the pain--warts and all.

Quick benefits WE gained OVER ASMX:

1) For internal (behind firewall) service-to-service calls we use the net:tcp binding, which is much faster than SOAP

2) We enabled both a net:tcp endpoint and a "web" endpoint on the same service with only a configuration file update (no code changes)

3) We were able to create AJAX-supporting RESTful web services with only configuration changes and using the DataContractJsonSerializer that's already built in. To do this otherwise, we would have had to write an HTTP Handler (ashx) and handle most of the Json serialization and url parsing by hand.

4) As our site needs to scale for performance optimization and stability, we are looking at converting to using an MSMQ-based messaging structure that is asynchronous AND guaranteed and participates in transactions; WCF provides an MSMQ bindng that requires little-to-no code change in our services--just reference updates and setting up MSMQ properly with the existing services (and adding attributes for Transactional boundaries).

BUT BE WARNED: Really invest in learning this (buy the blue O-Reily book and go through it). There are things like argument-name-changes during development that actually don't break the service references but result in null arguments being passed (built-in version skew handling), hosting models to consider (Windows Service vs. IIS), and instantiation models and FaultExceptions to all REALLY understand. We didn't going in and we had some pains. But we plowed ahead and are VERY happy with our learnings and the flexibility and growth opportunities we have not being tied to ASMX anymore!

Related Topic