Silverlight Tip of the Day #44: Silverlight-enabled WCF Services versus ASMX Web Services
In Tip of the Day #42 I talked about how to create and use a web service using WCF for your Silverlight application. For this tip I would like to briefly discuss WCF and some highlights on why you should use it over the traditional ASMX based Web Services. Also, I will be touching on what Silverlight-enabled WCF services gives you.
Highlights and Advantages of WCF:
- WCF stands for “Windows Communication Foundation”.
- WCF is Microsoft’s next generation platform for network distributed services that shipped as part of the .NET 3.0 framework. Call it the successor and unifier of most distributed systems out there today.
- WCF runtime resides under the System.ServiceModel namespace.
- In most cases WCF is significantly more performant (25%-50%) faster. See this MSDN article for comparisons.
- The throughput of WCF is inherently scalable from a single processor to a quad processor.
- The WCF model unifies the feature wealth of ASMX, WSE, Enterprise Services, MSMQ, and Remoting. This way, developers only have to master a single programming model.
- WCF can be hosted in IIS Servers, Windows services and standalone apps like windows forms, console apps.
- WCF provides a DataContractSerializer which allows complex data types and private attributes to be serialized and sent.
- WCF can have messages sent in a variety of channels including HTTP, TCP, MSMQ, Named pipe, etc.
The list goes on but hopefully this gives you a good starting point into why you should use WCF over traditional web services.
When adding a WCF service to your web site for Silverlight, make certain to choose “Silverlight-enabled WCF service” over the standard “WCF Service”. Since WCF is the best practice for writing services with Silverlight, Microsoft has provided this template as a way to get you a service that is already configured in a specific way for Silverlight. Primarily what is done for you is:
- Web.config is configured to use basicHttpBinding since Silverlight does not support ws*.
- ASP compatibility mode: <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
Thank you,
--Mike Snow
Subscribe in a reader