Chapter 12. Extending WCF Services

As we have learned from previous chapters, WCF provides a unified programming model for building service-oriented applications. With WCF, you can build secure, reliable, transacted solutions that integrate well across different platforms and interoperate with existing investments. The WCF programming model is very comprehensive, yet it is also very flexible. You can extend this model to enhance the functionality or customize the framework for your specific needs. In the last chapter of this book, we will explore extension points of WCF services and learn how to extend a WCF service.

We will cover the following topics in this chapter:

  • WCF runtime architecture
  • Why extend a WCF service?
  • Client-side extension points
  • Service-side extension points
  • Steps to extend a WCF service
  • How to extend the HelloWorldService

WCF runtime architecture

The WCF runtime provides a set of classes responsible for sending and receiving messages. For example, formatting messages, applying security, transmitting and receiving messages by using various transport protocols, as well as dispatching received messages to the appropriate operations, all fall within the WCF runtime scope.

The following diagram shows WCF runtime (http://msdn.microsoft.com/en-us/magazine/cc163302.aspx):

WCF runtime architecture

The sequence of a WCF service call might look as follows:

  • A client application calls a WCF service through a WCF proxy
  • The proxy translates the call to one or more WCF messages
  • The messages are passed through channels and transported to the service
  • On the service side, the messages are transported through channels
  • Service dispatchers pick up the messages, making calls to WCF services and then returning the results back to the client

As you can see from this diagram, there are multiple layers and many entry points for a WCF service call. At almost every entry point, there is a possible extension interface that you, as a WCF developer, can extend. In fact, there are over 30 extension points in the WCF runtime. In this chapter, we will explore some common extension points and we will extend our HelloWorldService to log incoming/outgoing messages.

Note

For a comprehensive list of WCF extension points, look at the MSDN documentation on WCF extensions. Additionally, you might want to check out the blog at http://blogs.msdn.com/b/carlosfigueira/archive/2011/03/14/wcf-extensibility.aspx for WCF extension points. (This blog explains many of the WCF extension points up to .NET Framework 4.0, but they are all valid for .NET 4.5.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset