Skip navigation

New Features in Windows Communication Foundation 4.0

Learn about the main new features in WCF 4.0 that make it easier to implement SOA applications

Windows Communication Foundation (WCF) is Microsoft's contribution toward developing a framework for building platform-independent, protocol-independent services. Released as part of Microsoft .NET Framework 3.0, it has quickly become the technology of choice for .NET developers for designing and implementing scalable services. WCF 4.0 provides many new interesting new features and enhancements. This article highlights the most useful of these new features and enhancements and illustrates them with code snippets wherever applicable.

What Is WCF?
WCF is a framework designed by Microsoft that's based on service-oriented architecture (SOA). It can be used to design SOA applications that can have the capability to inter-communicate. WCF was initially code-named "Indigo" and was made available as part of .NET Framework 3.0 in 2006. (See the WCF information on MSDN for more information.)

New Features and Enhancements in WCF 4.0
The main new features and enhancements in WCF 4 fall into these areas:

  • support for simplified configuration
  • support for routing service
  • support for simplified IIS hosting
  • support for REST-based services

Simplified Configuration
WCF 4.0 provides support for a simpler configuration. You no longer need to specify the tedious configuration details of the earlier versions of WCF for hosting your WCF 4.0 service now. Consider the following simple WCF service, shown in Figure 1.

Figure 2 shows all you need to write now in WCF 4.0 to host your WCF service. And Figure 3 shows what you can specify to consume your WCF service.

If you would prefer a more secure binding, like "wsHttpBinding", you can instead use the configuration that Figure 4 shows.



Support for Routing Service
WCF 4.0 provides excellent support for routing that determines how messages can be forwarded when a request comes in. You can use the RoutingService class in WCF 4.0 to implement generic routing mechanisms. The RoutingService class looks like that shown in Figure 5.

Note that hosting of a RoutingService in WCF 4.0 is much the same as hosting of any WCF 4.0 service. The WCF 4 routing service provides these features:

  • versioning support
  • message routing
  • transaction and error handling
  • protocol bridging

Support for Simplified IIS Hosting
WCF 4.0 now supports simpler configuration for hosting services in Microsoft IIS. Consider the WCF 4.0 service that Figure 6 shows.

To enable service metadata for the service you created earlier, you can specify the information shown in Figure 7 in the application's web.config file.

It is also possible to activate your WCF 4.0 service now without the need to create a .svc file. To do this, you need to define virtual service activation endpoints for the WCF 4.0 service you created in your application's web.config file, as Figure 8 shows.



Support for REST-Based Services
Representational State Transfer (REST) is an architectural paradigm for designing and developing scalable, interoperable services. WCF 4.0 now provides support for design and development of REST-based services. You can now even configure an automatic Help page that describes the REST-based services available for consumption by the service clients.

Figure 9 shows how you can configure support for an automatic Help page in your application's configuration file.

More on WCF 4
WCF facilitates design and development of REST-based and SOA services that can inter-communicate. It is a framework from Microsoft that provides a unification of a number of enterprise technologies under a single umbrella. This article gives you a jumping-off point for using the new WCF 4 features in your applications.

For more information about WCF 4, see these DevProConnections articles:

Joydip Kanjilal ([email protected]) is a Microsoft MVP in ASP.NET. He has more than 12 years of industry experience in IT with more than six years in Microsoft .NET and its related technologies.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish