Get DataContract DataMember Value from WCF Channel Message RRS feed

  • Question

  •    how to get the SOAP request value of datamember of datacontract  from WCF at AfterReceiveRequest method

        SOAP Request is

        <s:Envelope xmlns:s="" xmlns:a="">
        <a:Action s:mustUnderstand="1"></a:Action>
        <VsDebuggerCausalityData xmlns="">uIDPoyXtX3m/PSJBo+4Vd2taPwgAAAAAB+2JFplBDU6oJYlfkZ/um28yri7PLBZFmtLNf3F75EMACQAA</VsDebuggerCausalityData>
        <a:To s:mustUnderstand="1">net.tcp://localhost/mytcpservice/TcpService.svc</a:To>
        <GetData xmlns="">
        <value xmlns:b="" xmlns:i="">

        public class TestActivation : IDispatchMessageInspector
        public object AfterReceiveRequest(ref Message request, IClientChannel     channel, InstanceContext instanceContext)
        //here fetch Token value if exists

    fetch Token value by generic

    Tuesday, January 27, 2015 11:52 AM


  • Hi,

    At the server side, implementations of IDispatchMessageInspector get a chance to inspect the incoming message right after the request is received via the AfterReceiveRequest method. Besides the message, the method is also passed the channel through which the message arrived (which contains information about any current sessions, local and remote address, and so on), and the instance context associated with the service (with references to the host, and any extensions associated with it).

    One thing that deserves mention is that the Message object to both methods is passed by reference. WCF Message objects can only be “consumed” once – and “consumed” can mean read, written or copied. The message body is essentially a read-once stream, so once it’s consumed it cannot be used again. So if, in the inspector code, one were to read the message, the WCF runtime wouldn’t be able to reuse that message in the rest of its pipeline (i.e., to encode it to send as a reply or to parse it into operation parameters). So if the inspector code needs to read the message, it’s the responsibility of the inspector to recreate the message.

    For more information, you could refer to:


    Wednesday, January 28, 2015 7:18 AM