I am trying to log messages in WCF using the following code, but Message Body is not written properly; It’s written as >... stream ...</s:Body>. It used to write complete message body before with the same code.
public class MMServiceMessageInspector : IDispatchMessageInspector
{
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
{
MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue);
request = buffer.CreateMessage();
Helper.LogMessage("Received: " + buffer.CreateMessage().ToString());
return null;
}
}
That’s because the message is being streamed rather than buffered so it is not all in memory. Have you considered using the built in message logging functionality in the diagnostics?
Edit
To Force the contents of the message you can use the code discussed here