Last time when I talked about WCF and told to upgrade from Web Services to WCF, many of my friends asked me about the difference between the Web Services and WCF and why to upgrade. So now this blog entry explain why we need to upgrade from Web Services to WCF.
SOA initiatives using ASMX services and trying to reach out to all the stakeholders on internet using SOAP/http clients was the natural option, where as to connect with employees, internal users or partner’s it would have used TCP IP based .Net Remoting. Thus to serve different user base, one has to use different transport option and each transport needed independent implementation.
Unlike ASMX services which were primarily Http based, WCF Services can be reached using multiple protocols like Http, TCP IP, Named Pipe and MSMQ. Other clients like internet/intranet or partners can use any of the above mentioned preferred channels to hook on to these services without IT having to maintain separate code base to serve different client class.
Large Enterprises having mix of technologies, Interoperability requirements with Non Microsoft clients is one of the common scenarios in any SOA initiatives. With ASMX WS-*, XML Serialization is not standardized and hence it is difficult to achieve true interoperability. With WCF, it generates standard SOAP based XML to be consumed by clients. Additionally by using data contracts and message contracts, information exchange with non Microsoft clients’ become easy and improves interoperability.
Most often sharpness of underlying technology contributes in meeting performance based business SLAs (e.g. In banking gateway for Money transfer, Number of clients served per second). ASMX services were part of .net framework 2.0, since then with .net 3.5 and 4.0 around, there has been continuous improvements in core .net framework to improve performance.
One of the key reasons WCF performance is better than ASMX services is due to the improved serialization techniques in the .net framework. WCF services provide 25 to 40% improvement in performance over ASMX services and hence become natural preference for high performance application.
If ASMX services were to be delivered to clients, only possible way to host them was on to IIS (Internet Information Server). With WCF services, one can host the services into Windows services, Windows Activation Service (WAS) or IIS. WCF also supports claims based authorization which is more granular than existing mechanisms. With WCF starting from application runtime, security, binding, serialization, channel system to service host everything is extensible.
ASMX with WSE 3.0 supports security and http buffering/caching/sessions but still lacks support for Session management, Concurrency, Security, Reliable messaging, Transaction, Throttling, Exception handling and faults. In applications explicitly using WSE to support some of these features is difficult and cumbersome, where as with WCF WSE is inbuilt.
With .Net 4.0, the argument to migrate becomes even stronger because of the benefit from platform features like CLR enhancements, Improved Garbage collection, Parallel programming, Distributed caching, and improved support for REST, and Workflow Services.
With above benefits making way to WCF migration, one of the ways to solve service migration problem is by overlaying WCF attribute over ASMX attributes. e.g. With ServiceContract() attribute on ASMX Service class, and OperationContract() on service methods/operations and then making appropriate changes in .config file. This wrapper based approach may make asmx services work with asmx and wcf clients. But with this approach, since the underlying code is still asmx, it will not benefit from the underlying framework advantages that WCF provides as discussed above.