Wednesday, March 21, 2012

Difference between WCF vs. Web Services (ASMX)

Categories WCF ASMX (Web Services)
Protocols Support
  1. HTTP
  2. TCP
  3. Name Pipes
  4. MSMQ
  5. Custom
  6. UDP
  1. HTTP
Hosting
  1. A WCF component can be hosted in any kind of environment in .NET 3.0, such as a console application, Windows application, or IIS.
  2. WCF services are known as 'services' as opposed to web services because you can host services without a web server.
  3. Self-hosting the services gives you the flexibility to use transports other than HTTP.
Can be hosted only with HttpRuntime on IIS

WCF Backwards Compatibility

  • The purpose of WCF is to provide a unified programming model for distributed applications.
  • Backwards compatibility
  • WCF takes all the capabilities of the existing technology stacks while not relying upon any of them.
  • Applications built with these earlier technologies will continue to work unchanged on systems with WCF installed.
  • Existing applications are able to upgrade with WCF
  • New WCF transacted application will work with existing transaction application built on System.Transactions

WCF & ASMX Integration

  • WCF can use WS-* or HTTP bindings to communicate with ASMX pages

Limitations of ASMX:

  • An ASMX page doesn’t tell you how to deliver it over the transports and to use a specific type of security. This is something that WCF enhances quite significantly.
  • ASMX has a tight coupling with the HTTP runtime and the dependence on IIS to host it. WCF can be hosted by any Windows process that is able to host the .NET Framework 3.0.
  • ASMX service is instantiated on a per-call basis, while WCF gives you flexibility by providing various instancing options such as Singleton, private session, per call.
  • ASMX provides the way for interoperability but it does not provide or guarantee end-to-end security or reliable communication.

WCF is far wider in scope than ASP.Net webservices.

  • WCF can run in any application. APS.Net webservices only run in IIS.
  • WCF supports models like ReST, Remoting, SOAP, MSMQ etc. ASP.Net only supports SOAP
  • WCF is more configurable.
  • WCF supports a more declarative way of programming. You can get more done with less code.

ASP.NET Web Services are pretty much just that. Web Services. They're SOAP/WSDL based and provide their services only to the web.

WCF Services offer a much more flexible framework. For instance, depending on how the service is defined, it can be a Web Service hosted in IIS which serialized its data via XML and uses the REST model...or it can be a Remote Windows Service that is hosted in it's own process and serializes its data via binary. All of this is achieved using the different Service/Data contracts in WCF.

In short...you can make a WCF service look almost identical to a .NET 2.0 Web Service fairly easily but, with a little work, you can do a WHOLE LOT MORE.

Happy Programming Thumbs up

2 comments: