I am attempting to read the raw XML of an MSMQ message and save it to an XML file. For instance, the MSMQ message with body:
<?xml version="1.0"?>
<string>Hello World! I am message #4</string>
I would like to take those exact xml lines and save them to a file message.xml.
I have the message reading like the below:
msg = queue.PeekById(enumerator.Current.Id);
msg.Formatter = new XmlMessageFormatter(new String[] { "System.String,mscorlib" });
System.IO.File.WriteAllText(dirPath + @"\" + msg.Label.Replace(@"\","").Replace(@".","") + enumerator.Current.Id.Replace(@"\","").Replace(@".","") + "_" + DateTime.Now.ToString("MMddyyyyhhmmss") + ".xml", msg.Body.ToString());
queue.ReceiveById(enumerator.Current.Id);
logEntry("*-Received Message with Id " + msg.Id + " and Label " + msg.Label);
But that only pulls the text "Hello World! I am message #4" and I want the full xml.
No comments:
Post a Comment