Is there something I can hook into that will fire every time a method is called on my wcf service? I 开发者_开发百科looked at adding an operation invoker but I was hoping there was something more simple. Plus I'd rather not add attributes to everything in the contract.
Is there something I can hook into that will fire every time a method is called on my wcf service?
You could use a message inspector.
In addition to the message inspector Darin mentioned you can also use a parameter inspector. The message inspector gives you more information, but you need to get this information from a Message object; the parameter inspector only gives you the operation name and the parameters (and returns) passed to (returned from) the methods, but you get the actual objects which in many cases is more convenient.
And for decorating everything in the contract, you only need one endpoint/contract behavior, and that behavior would enumerate the operations and add the inspectors for them.
精彩评论