When you do a Google search on “ASMX vs. WCF” or similar you will find a lot of results. This is how I see it:
A man called Smith ordered a Regina pizza with broccoli from his local pizzeria. The man behind the counter was stunned. Why would anybody order this particular pizza? He asked the man if he would be interested in the new, awesome pizza, namely a Regina base with broccoli, pepperoni, bacon, avocado, steak, mushroom, three cheeses and pike.
The little scenario above is a mediocre comparison between ASMX* web services and the new WCF*. Although broccoli (ASMX) is still an excellent technology, there are better, newer pizzas out there (WCF).
I’ll admit it is easy to eat the broccoli pizza without making a mess. A description of what your service methods and classes will look like is stored in a WSDL*. Now, we simply decorate a method (inside a .asmx) with the [WebMethod] attribute and viola, any property with public accessors and modifiers we pass in or out, will be serialized into XML. Your method can now be called over HTTP and hosted on an IIS.
The snags with broccoli, uhm, let me think…to name a few:
- ASMX doesn’t specify how to deliver over the transports and to use a specific type of security.
- ASMX has a tight coupling with the HTTP runtime and is dependent on IIS to host it.
- ASMX service is instantiated on a per-call basis
- ASMX provides the way for interoperability but it does not provide or guarantee end-to-end security or reliable communication.
Now, let's discuss the pizza with all the new toppings. WCF irons out all of the concerns listed above and replaces all the following technologies: ASMX, MSMQ*, WSE*, COM+ and .Net Remoting.
You might have noticed that one of the toppings in my metaphor, pike, has no business being on my pizza. This represents the configuration that is keeping a lot of developers from implementing WCF. With WCF the configuration might be a bit “messy”, but the reward is an awesome, tasty pizza. From a developer's point of view the coding side stays the same, the bottom line being a method gets called with an “object” as parameter and an “object” is returned (To get the technical lingo out of the way…we call this a message).
We no longer decorate only the method, but an interface, meaning any class that implements the interface can be a service. We are no longer limited to hosting the service only on an IIS, but in Console Apps, Windows Forms, WPF, etc. A description of the Service is still stored in a WSDL (.Net 4 has support for WSDL 2.0)
WCF is the future of the .Net platform, thus it will be time wisely spent to familiarise, educate and become proficient in it. If you have been holding back I encourage you to forget about your trusty broccoli pizza and reap the benefits of a pizza with a lot of awesome toppings.
Definitions
- ASMX: Active Server Method File
- WCF: Widows Communication Foundation
- WSDL: Web Service Description Language
- MSMQ: Microsoft Message Queuing
- WSE: Web Services Enhancements
No comments:
Post a Comment