tags:

views:

276

answers:

1

I've written a WCF IDispatchMessageInspector, so I can log incomming and outgoing messages. But I'm not sure how to get a nicely-formatted XML string to log.

My code looks something like this:

        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
    {
        MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue);
        request = buffer.CreateMessage();
        Log("Received", request.ToString();
        return null;
    }

The result of this logging includes things like "ampersand lt;" and some sort of binary-encoded data.

How do I get something that looks like a standard soap XML document? I know this should be obvious, but I'm just too dense to figure it out.

Thanks.

Dan

A: 

Is there any specific reason you are not using the .Net build in tracing functionality with an XmlTextWriter output?

If no specific reason, have a look at http://msdn.microsoft.com/en-us/library/ms730064.aspx

Hope this helps,

Marvin Smit