XMLDocument and MSMQ

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have several programs (.net and other) that use the framework to insert
objects into the message queue. The object of choice is the XMLDocument.
There is no problem inserting the XMLDocument into the message queue, however
i can not seem to get the XMLDocument back out of the queue. How do i
De-Serialize the XMLDocument from the message body? Is there a better way?
It has to be a XMLDocument going in, but if i can get out a string or
anything and load it back to a XMLDocument that will work to.

Thanks

Eric
 
See: MessageQueue.Formatter.

To de-serialise messages off the queue for a program that I wrote for a
client, we did something like this:

// Declare and setup the message queue
// Set formatter
messageQueue.Formatter = new System.Messaging.XmlMessageFormatter(new Type[]
{typeof(string)});

// Get a message off the queue (myMessage is System.Messaging.Message)
myMessage = messageQueue.Receive(new TimeSpan(0, 0, m_timeout),
messageQueueTran);

// Get the body of the message
string msg = (string)myMessage.Body;

In the end, our "msg" contained XML that was then parsed and passed into
another system, but it sounds like this is what you are attempting to do.

Hopefully this helps.
 
Back
Top