WCF and custom behaviors exceptions

I encountered interesting issue with WCF today. When calling a service method on the client side, I sometimes received fault with the following message:

The message with Action ‘SomeUri/Foo/Bar’ cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

Turns out that this message is misleading. The real issue was, that custom ParameterInspector I had on the service side happened to throw an ArgumentNullException. This was silently caught by the WCF, which interpreted it as contract mismatch and that fault message was sent back.

Adding additional parameter checking in ParameterInspector fixed the issue.

Hope that helps.


Technorati Tags: