I'm trying to gain a better understanding of WCF's dispatch process in particular the impact and effect on the various extensibility points. From the web pages listed at the bottom, it appears that WCF will do the following in the stated sequence once a message is passed to the dispatcher by the channel stack.
- Message Inspector
- Operation Selector
- Message Formatting
- Parameter Inspector
- Operation Invoker.
I'm trying to find some options to resolve an issue I have and one way I'm thinking of is to use a combination of Message Inspector, Operation Selector, Message Formatting and Operation Invoker. Unfortunately, my observation seems to indicate the sequence of execution is as follows instead:
- Operation Selector
- Message Inspector
- Operation Invoker (AllocateInputs())
- Message Formatting
- Parameter Inspector
- Operation Invoker (Invoke())
I can understand the slight difference where a custom invoker AllocateInputs() method is called before formatting the message as the Message Formatting section is essentially deserialising the given message into a set of method arguments to be passed on to the appropriate operation and the invoker's AllocateInputs() method specifies how many parameters are expected.
The part that throws me is the inversion of sequence between Message Inspector and Operation Selector. It sounds logical to me for Message Inspectors to be run through first as they act on the message whereas Operation Selector determines which service operation the message is targeted for.
Questions:
- Is that due to different versions or releases of WCF?
- Is this because WCF does not actually specify extensibility points execution sequence?
Reference pages:
Extending WCF to support custom data formats - Zulfiqar's weblog
Extending WCF with Custom Behaviours - MSDN Service Station December 2007
Message Flow Interception Points - Nicholas Allen's Indigo Blog
Note: My apologies for not providing links, can't have more than one since I'm still a noob. =)
To determine the actual order that the code executes in I would recommend turning on Tracing for WCF and look over the generated trace logs. This can be enabled by adding this to the config file:
As far as the extensibility points in WCF, Carlos Figueira (one of the engineers of WCF at Microsoft) has a post detailing almost all of the extensibility points in WCF ( http://blogs.msdn.com/b/carlosfigueira/archive/2011/03/14/wcf-extensibility.aspx ).
In the WCF Runtime section of this post the ordering is listed as such:
I think between the two the order of operations in WCF should become clear.