c# - How to get type(as in request.GetType) of a request message in Service Behavior of WCF Service -


i writing custom servicebehavior expects me know type of request message infer if message decorated custom attribute.

my sample contract like:

    [datacontract] [auditable] public class compositetype {     bool boolvalue = true;     string stringvalue = "hello ";      [datamember]     [audit]     public bool boolvalue     {         { return boolvalue; }         set { boolvalue = value; }     }      [datamember]     [audit]     public string stringvalue     {         { return stringvalue; }         set { stringvalue = value; }     } } 

i trying identify custom attribute on behavior side using :

public object afterreceiverequest(ref message request, iclientchannel channel,     instancecontext instancecontext) {     var typeofrequest = request.gettype();      if (!typeofrequest.getcustomattributes(typeof (auditableattribute), false).any())     {         return null;     } } 

but typeofrequest coming in {name = "bufferedmessage" fullname = "system.servicemodel.channels.bufferedmessage"}

is there way can infer type of message using request ?

note: have direct reference assembly holds contract , service not referred through wsdl.

the solution above problem not use messageinspector (as in idispatchmessageinspector or iclientmessageinspector) instead use parameter inspector (as in iparameterinspector).

in beforecall method can like:

public object beforecall(string operationname, object[] inputs) {          var request = inputs[0];          var typeofrequest = request.gettype();          if (!typeofrequest.getcustomattributes(typeof(customattribute), false).any())         {             return null;         } } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -