WCF Extensibility - Part 1

Tags: .NET, NETFX3, SOA, WCF

What we have in WCF

WCF has a design that clearly shows a very hard work of many talented people for a long time, and that kind of effort can only be a good thing.

The first thing you note when start working with WCF is the simplicity of the programming model, a thing that COM+ and Enterprise Services was very good at providing some interesting programming models, like declarative programming using attributes, that WCF tried to incorporate.

After that first impression you start digging a little more into the WCF inner workings and you note that it has all the flexibility and extensibility of WSE and Remoting, and then some more, and also supports the communication style of Remoting (although the WCF team doesn't want to encourage its use) side by side with the full Service Orientation support.

As WCF really is the unification of all previous communication technologies and development paradigms for application and integration scenarios, we can expect to find a more complex architecture underneath, and as I said before it can be a little intimidating when you start looking into all those interfaces and options for extensibility.

WCF Architecture

Figure 1. WCF Architecture

As we can see in the simplified architecture diagram shown above, WCF has two main layers where extensibility can be applied and the first decision you have to make is at what layer you need to apply the extensibility you need:

  1. Customizations at the service model level: this is the higher level of abstraction in WCF and they apply to the higher level constructs like service, contracts and operations. Most common customizations are made at this level and they relate to the fact that you can change the local behavior of any of those service constructs.
  2. Customizations at the messaging level: this is the lower level of the WCF infrastructure where you have protocols and transport channels. In this layer the message is serialized and transmitted using the selected transport, also protocol rules are applied (like reliable messaging) and security (like encryption). Customizations here are needed when you need to modify "what's on the wire".

Other extensibility points beyond these two include Bindings, Security, Metadata, Serializers and Hosting but they are somewhat less common in typical applications.

The three ways of customizing the service layer include:

  • Manipulate the Service Description.
  • Injecting Behaviors by hand.
  • Overriding ServiceHost / ChannelFactory<T>.

We are going to dive into these three customization methods in the next posts.

Next post: WCF Service Description Layer

 Enjoy!

Andrés G Vettori
MCSE/MCSD/MCT
EDS Top Gun - .NET Capability Architect

Leader of the C# Community of the Microsoft Users Group Argentina

No Comments