Поделиться через


ASP.NET Web Services to WCF services: Answering the question - Why?

Windows Communication Foundation (WCF) is the platform for building distributed applications.  Developers are usually eager to adopt the latest of any technology because, well, it’s the latest.  There’s an element of coolness associated with building systems using the latest and greatest technology.  Management, on the other hand, often takes a different look at technology to understand what the “value” is that a technology will bring to the bottom line. 

So, in this post, I’m going to shine a light on why you would migrate to WCF from past technologies, such as ASP.NET Web Services.

Productivity

Developer productivity is something that translates directly to the bottom line and WCF nails this one on the head, especially with the Visual Studio 2008 release and even more with SP1 for Visual Studio 2008.  Thanks to the WCF Service Host and WCF Test Client, you can literally have a service running and tested in seconds (I can do it in about 10 seconds).  Of course, you have to make the service your own and add your business logic, but the tooling for WCF will give you a working service right out the box that is secure, interoperable, and provides better performance (see Performance below).  You can create an ASP.NET Web Service and test it in the browser in about the same amount of time, but your ASP.NET Web Service won’t come close to matching the features you get right away from a WCF Service.  I’ll cover many of these features in the sections to follow.

Security

In WCF, all the bindings (except basicHttpBinding) are secure by default.  This means that messages are encrypted, signed, and transmitted between authenticated parties, to thwart message tampering and information disclosure threats.  Secure message transfer is obtained through either transport security, message security, or combination of both.  Auditing of security events such as authentication and authorization is built in and can be leveraged by simply applying an auditing behavior to your service.  There is a wealth of security guidance and best practices for WCF that can be found here and here.  In today’s hostile online world, more and more businesses are realizing the significant costs that can be incurred by insecure systems.  Since WCF provides security by default it helps mitigate security risks and the associated costs.

Interoperability

Providing an implementation of the WS-* specifications was one of the key drivers for WCF since it’s first release in .NET Framework 3.0.  In .NET Framework 3.5, this story got even better providing first class support for REST, Syndication, AJAX and providing data serialization to support things like JSON, POX, RSS, ATOM.  With all of these options, WCF enables you to expand the reach of your service, opening the door to potential new business opportunities. 

Performance

WCF offers better performance, about 25% – 50% faster than ASP.NET Web Services.

Features

WCF offers more hosting options unlike ASP.NET Web Services that require you host in IIS.  WCF services can be hosted in IIS, IIS7/WAS on Windows Server 2008, Windows Services, WinForms or WPF (good choice if your service is part of a peer-to-peer application).  Basically, any managed process can be a host for WCF Services.

WCF offers more transports than just HTTP.  Out of the box you get bindings support for HTTP, TCP, Named Pipes and MSMQ. 

Extensible Architecture

If for some reason WCF doesn’t offer something you need, then you can extend the architecture.  For example, if you need support for a protocol that’s not already provided, then you can create your own and just add it.  This UDP sample is an example.

The release of .NET Framework 3.5 (looking at it through a WCF lens) is validation of the extensibility of WCF.  For example, in this release, programming WCF services for the web was the primary focus, allowing us to expose services through non-SOAP endpoints.  Here we saw the introduction of things like the WebGetAttribute, WebInvokeAttribute and the WebHttpBehavior that are simply implementations of IOperationBehavior and IEndpointBehavior.  These interfaces are basically extensibility points that have existed since WCF’s initial release in .NET Framework 3.0.

So, if for some reason you need to add new functionality that WCF doesn’t already provide, then you can rest assured that your ability to extend WCF to meet your needs is a real and supported path.

Integration

Leverage the investments made in previous technologies.  Management never likes to hear that you have to re-write everything before you can start to realize the benefits of a newer technology.  WCF offers a great integration story with respect to ASP.NET Web Services.  It also offers tools and support for integration with existing COM+ applications and MSMQ applications.

More Effective Troubleshooting

Should you need to troubleshoot a WCF service, then you have a wealth of features and tools you can take advantage of.  Message logging, tracing, performance counters, and WMI Support are available through simple configuration file changes and the Service Trace Viewer makes it very easy to interpret message logs and trace logs.  In most cases, you can effectively troubleshoot issues without having to resort to more heavy-handed approaches that typically require debugging tools be installed into production environments.

Return On Investment (ROI)

The decision to adopt a new technology has to offer the business a return on the investment – otherwise, why do it.  Hopefully by now, you’ve realized that the investment is relatively small with respect to WCF because it does so much for you.  Management often wants to know that the decision to adopt a technology is one that will be backed by the vendor providing it.  WCF is that technology moving forward.  Technologies that preceded WCF (.NET Remoting, ASP.NET Web Services, Messaging, COM+) will continue to be supported.  However, the investment being made moving forward will be in WCF.