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