WCF is a very powerful tool for developers, and I’m sure as you dive in to the development environment you will come across the WCF Message, which is part of System.ServiceModel.Channels Namespace. You should be aware that a message body can only be accessed once and a message can only be written once. This will in turn can cause a problem if you are creating your own IDispatchMessageInspector, as at some you will need to read the message and once you have read it, you are buggered!
So in order to use the Message you will have to copy the message in to a buffer using the CreateBufferCopy method, here is how you go about it
public void Validate(ref Message message)
{
MessageBuffer buffer = message.CreateBufferedCopy(int.MaxValue);
try
{
ValidateInput(buffer.CreateMessage());
}
catch (Exception)
{
throw;
}
message = buffer.CreateMessage();
}