The question is in AfterReceiveRequest how to find out the custom attribute set on the Operation using the OperationDescription? If there's a way, is it better to set the custom attribute on operation declaration in service contract interface or the service implementation class?
To illustrate the question further:
public interface IGetterSetterService
{
[OperationContract, GetterRequest]
Data[] GetData();
[OperationContract, SetterRequest]
bool SetData(string Data);
}
OR
[WebInvoke(Method = "*", ResponseFormat = WebMessageFormat.Json, UriTemplate = "xyz"]
[GetterRequest]
public Data[] GetData()
{
return new Data[];
}
[WebInvoke(Method = "*", ResponseFormat = WebMessageformat.Json, UriTemplate = "xyz/{data}"]
[SetterRequest]
public bool SetData(string data)
{
return true;
}
Now the IDispatchMessageInspector:
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
{
//Here how to find out the GetterRequest or SetterRequest custom attribute set on an
//operation, may be using OperationDescription for the current context?
}
My complete solution looks like this and it works without any problem:
1. First get the operation description as discussed here
2. Then find the custom attributes set on Operations in Service interface: