I have defined a custom OperationSelector that implements IDispatchOperationSelector so that I can intercept the message from the client prior to executing the method. I am doing this so I can check public/private key values included in the message, and throw an Authorization fault if needed without putting any auth logic in my services.
This all works fine thus far, but I would like to specify a [AuthenticationType] attribute for each service operation, that I can check i this OperationSelector. Is there anyway I can reference, or find the corresponding conctract and operation in the OperationSelector? If so, how?
I would recommend mixing both a
MessageInspectorapplied to the whole contract, and then creating anOperationBehaviorthat will register the operation name on the underlyingMessageInspector.Similar to what is shown here: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/bcd94cf9-2881-4081-a05b-771a6e6f9c06/ (Carlos Figueira’s answer)
That way, your message inspector will end up with a list of all registered operations with the attribute, and the inspector can identify which require validation and which don’t.