We've been looking at the flow of messages (Part 1 and Part 2), but have never stopped along the way to look at the extensibility points where you can plug in your own code. Being a highly-extensible framework, WCF has piles and piles of these extensibility points. Some of the extensibility points are more likely than others to be confused with the proper use of channels. I'm just going to list out a sequence of points, not intended to be exhaustive, where you can execute custom code in the message flow. We'll go in chronological order from the client to the server to match the earlier articles.
- Client code- Obviously, you have total control here over when service methods get called.
- Generated client proxy- If your proxy object is generated ahead of time instead of dynamically, then you can extend the proxy to run code whenever a particular service method is invoked.
- Message serializer- The message serializer sits below the proxy and converts CLR objects into an XML message.
- Client message inspector- The client-side message inspector lives above the channel stack and is the first one to see the newly-generated XML message. You could alternatively have added a new channel to the top of the channel stack.
- Client channel stack- The channel stack has all of the protocol and transport channels that were specified in your binding.
- Network intermediaries- Once on the wire, anything can happen to the byte stream during transmission.
- Service activation- Service activation is an optional layer that automatically controls the lifetime of service processes.
- Service host- The host of the service actually has many extensibility points inside. You can replace the factory that is used to stamp out host instances or you can modify the behavior of the host itself.
- Service channel stack- The service channel stack is the receive-side collection of protocol and transport channels.
- Dispatch message inspector- A server-side message inspector lives above the service channel stack and functions similarly to its client-side equivalent.
- Dispatch operation selector- Once we've gotten the message into a particular service, we need to figure out which one of the service operations is being called.
- Message deserializer- Message deserialization reverses the serialization process by converting an XML message back into CLR objects.
- Dispatch parameter inspector- Parameter inspection is the equivalent of a message inspector for the CLR objects that get produced during deserialization.
- Dispatch operation invoker- We know which call to make and what information to give it. Now, we just need to make that call.
- Service code- Again, you have total control over what happens inside the service method.
Next time: Channel Shapes