tags:

views:

232

answers:

2

Hi All,

I have a message contract which i am passing to my wcf service and i am having a message inspector which i m using to find what was sent by the wcf client. I have the Message but i don't know how to get the data from it. following is my message request which i am passing to wcf service.

[MessageContract]
   public  class MyMessageRequest
    {
        [MessageBodyMember]
        public string Response
        {
            get;
            set;
        }

        [MessageHeader]
        public string ExtraValues
        {
            get;
            set;
        }

    }

The method where i am getting the Message is following:

public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
                MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue);

                request = buffer.CreateMessage();
                Console.WriteLine("Received:\n{0}", buffer.CreateMessage().ToString());
                return null;
        }

I want to see the values of Response and ExtraValues out of the message , Please anyone help me out in this.

+2  A: 

I think you want

http://msdn.microsoft.com/en-us/library/system.servicemodel.description.typedmessageconverter.frommessage.aspx

where a

(new TypedMessageConverter<MyMessageRequest>()).FromMessage(msg)

will give you back the object you need.

Brian
I don't find any generic TypedMessageConverter . Where is it , can u pls tell me the namespace?
Praveen
The namespace appears in both the URL and at the top of the documentation page I linked (System.ServiceModel.Description).
Brian
A: 

To follow on to Brian's answer

TypedMessageConverter is in the System.ServiceModel.Description namespace

Shiraz Bhaiji