I want to store WCF messages in some storage and read them later on in order to "replay" them again.
Attached some code parts:
private void WriteMessage(Message message, string path)
FileStream fileStream = new FileStream(path, FileMode.Create);
using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(fileStream))
using (XmlDictionaryReader reader = message.GetReaderAtBodyContents())
private Message ReadMessage(string path)
using (FileStream fs = File.OpenRead(path))
using (XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader(fs, XmlDictionaryReaderQuotas.Max))
Message message = Message.CreateMessage(reader, int.MaxValue, messageVersion);
problem is that before storing the message, the Message.ToString() returns the message string as it's should like, the whole message, but after reading it, the ToString() shows the body as "... stream ..." and that's it.
Many thanks :-)
Please note: at the "WriteMessage" only the body is read and written as the message is wrapped in another message.
Have a look at Charles, you can easily store a session and then play it again or even edit individual requests and change the hostname, etc. We use it to generate test sessions, save them, and then replay the sessions with bots to generate a useful load test.
The only downside is the evaluation version only works for 30 mins, but hey, if you use it all the time then it's well worth the 50 bucks the full license cost.