Reputation: 3799
I have a simple IClientMessageInspector:
public class ConsoleMessageTracer : IClientMessageInspector
{
public void AfterReceiveReply(ref Message reply, object correlationState)
{
Console.WriteLine(reply.ToString());
}
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
Console.WriteLine(request.ToString());
}
}
AfterReceiveReply
works fine, but in BeforeSendRequest
only ... Datastream ...
is written to the console.
(Actually it writes ... Datenstrom ...
since I have a german installation of .Net and Thread.CurrentThread.CurrentCulture
seems to be ignored.)
How can I access the actual body of my request-message?
Upvotes: 1
Views: 1241
Reputation: 7264
You need to read the stream to get the entire message. However, you also need to make sure that you do so in a way that allows the message to be read/written afterwards. Please refer to this explanation for full details on how to achieve this.
Upvotes: 1
Reputation: 28980
Hello you can try with this code - InputStream
string documentContents = string.Empty;
using (Stream receiveStream = Request.InputStream)
{
using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
{
documentContents = readStream.ReadToEnd();
}
}
Upvotes: 0