Over the next months I intend on writing a series of posts about the (many) extensibility points from WCF (up to .NET Framework 4.0). The cadence should be around one new post every 1-2 weeks (depending on the workload I have at work).
WCF is a very powerful framework for creating distributed, service-oriented applications, and if you want to stick to defining a few operations, exposing them to a service over one of the pre-defined bindings, and consuming them in a client, you can look at any of the many “hello world” examples out there and that will be enough. However, if you want to do something a little differently, almost everything (as I’ve found out while answering to questions on the WCF MSDN Forum and other sources of user complaint feedback) can be accomplished using one of the extensibility points in WCF.
The biggest problem is which one. There are over 30 different points in which one can hook up code in the whole WCF pipeline (including serialization and the service model) that most people simply get too confused about which one is the right for their specific scenario (and sometimes a solution actually needs code in more than one of those places to work together). I’ve worked with WCF for over 6 years now (since before it was released), and I still don’t know all of them (and this series will be a good motivation for me to learn more about the product I work on).
In each post, I’ll talk about one of the extensibility points. My plan is to present some scenarios in which it can help, and always have code samples for them. Whenever applicable, I’ll talk about different ways of accessing that extensibility point, and some tips about the specific hook which may not be present in the “official” MSDN documentation.
Here’s a list of topics I plan on writing about. It won’t be necessarily done in this order (I’ll likely write about the most used ones first, or one for which I’ve seen an issue at that week), and I may add more items to this index if I find (or remember) any more.
1. Service model extensibility
1.2. WCF Runtime
1.2.1. Message interception
1.2.2. Mapping between message and operation parameter
1.2.3. Mapping between message and CLR operations
1.2.4. Instance [context] creation / initialization
1.2.5. Error handling
22.214.171.124. Initializer interfaces (IInstanceContextInitializer / IChannelInitializer / ICallContextInitializer)
1.3. Exposing / consuming metadata
1.3.2. IWsdlImportExtension (and IOperationContractGenerationExtension / IServiceContractGenerationExtension)
1.4.2. BindingElementExtensionElement / StandardBindingElement / StandardBindingCollectionElement
1.5. Web Hosting
1.6. WCF REST (3.5 / 4.0 model)
1.6.2. Extending WebHttpBehavior
1.7.1. Extensible objects: IExtensibleObject<T> and IExtension<T>
2. Channel extensibility
2.1. Protocol channels (client)
2.2. Protocol channels (server)
2.3. Message encoders
2.4. Transport channels
2.4.1. Request transport channels – part 1 (synchronous path)
2.4.2. Request transport channels – part 2 (interaction with runtime extensions)
2.4.3. Request transport channels – part 3 (asynchronous path)
2.4.4. Reply transport channels
2.4.5. Duplex transport channels
3. Serialization extensibility
3.1. Serialization callbacks (On[Ser/Deser]ializ[ing/ed])
3.4. IExtensibleDataObject / IDeserializationCallback / IObjectReference
4. Miscellaneous extensibility scenarios
4.1. Hooking into the tracing mechanism
4.2. Custom serialization in Silverlight 4
4.3. Extensibility in Windows Phone / Silverlight 3
4.4. WCF RIA Services
5. Wrapping up
I hope you find this upcoming series interesting, and I’m looking forward to your feedback – I’ll bring them to the team to the best of my abilities.
By the way, the WCF team is aware that, although very powerful, the framework can sometimes be hard to use. One of the main focus of the upcoming release is exactly making it simpler to create / configure / consume WCF services.