86022

Store And Replay WCF Messages

Question:

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())
{
message.WriteBodyContents(writer);
writer.Flush();
}
}
}

private Message ReadMessage(string path)
{
using (FileStream fs = File.OpenRead(path))
{
using (XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader(fs, XmlDictionaryReaderQuotas.Max))
{
fs.Flush();
Message message = Message.CreateMessage(reader, int.MaxValue, messageVersion);
return message.CreateBufferedCopy(int.MaxValue).CreateMessage();
}
}
}

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.

please advaice
Many thanks :-)

Please note: at the "WriteMessage" only the body is read and written as the message is wrapped in another message.

Answer1:

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.



Recommend

  • XML Parsing - NSXMLParserErrorDomain error 5
  • NamedPipeServerStream receive MAX=1024 bytes, why?
  • What does this mean? “Notice: ob_flush() [ref.outcontrol]: failed to flush buffer zlib output compre
  • Writing a backspace in a file
  • Persistent subprocess.Popen session
  • How can i know how many queries are fired in my database?
  • Attaching an image to an email
  • Socket Java client - Python Server
  • Animation of div doesn't stop after hover event ends
  • Pretty print html output from Jekyll
  • Why or how is it that is my path is not being respected MacOSX? [closed]
  • Doctrine2: Unable to override generated value strategy?
  • Annoying tick with speex [closed]
  • How to override FOSUserBundle/Doctrine/UserManager.php
  • what does null entities are not supported by org.hibernate.event.def.EventCache mean?
  • Cache Expiration event asp.net enterprise library
  • php - output values to screen mid loop
  • How do I flush NSLog's buffer?
  • Asp.NET MVC, custom TextWriterTraceListener does not create a file
  • Closing a connection early with PHP
  • Doctrine2 entity with varchar id don't insert id into database
  • Multithreaded Server receives data from just one client JAVA
  • Textview values does not update when data received from Arduino
  • Create CSV file from c#: extra character in excel
  • networkstream “cannot access a disposed object” when using newly created networkstream
  • Standard way for writing a debug mode in C++
  • Complex python3 csv scraper
  • ZF2 Doctrine: When to flush ObjectManager
  • How could I write a BsonDocument object into a file, and read it again, using Java
  • java.io.EOFException when sending serialized data to a servlet
  • Input buffer flush
  • Streaming data from a NVarchar(Max) column using c#
  • python - calculate orthographic similarity between words of a list
  • How to handle empty space in url when downloading image from web?
  • Iterate twice through a DataReader
  • Python to parent/child JSON
  • How to Save JSON data to SQL server database in C#?
  • Ajax Upload File: $_FILES is empty but files exists in request header
  • Is there a way to do normal logging with EureakLog?
  • PHP buffered output depending on server setting?