How to send/receive XmlDocument objects via a message queue?

Posted on 2005-04-27
Last Modified: 2010-08-05
The XmlDocument object already includes the messages i want to send in xml format. So i dont need to use the XmlMessageFormatter to serialize the object into xml format? How could i send the XmlDocument object via a message queue? Do I need to serialzie it in another way? Thanks a lot!
Question by:heyday2004
    LVL 7

    Expert Comment

    Actually you could send as text like...

    XmlDocument doc = your xml Document.

    that will give you the complete string representation of the XmlDoc.  Then when you get the string on the other side you can do

    string xmlStr = string from MSMQ
    XmlDocument doc = new XmlDocument();
    doc.LoadXml( xmlStr )


    Author Comment

    Thanks. Do I need to serialize the class? Isn't it a must that every class sent to the queue must be Serializable? Actually, I really don't quite understand serialization here. Thanks.
    LVL 7

    Accepted Solution

    Well if you were trying to send a class then yes... However, you are sending a string.... The doc.OuterXml serializes the XmlDocument into a string with xml tags.  The doc.LoadXml(xmlStr) then puts that string back into an xml document.  Now if you wanted to send a class then you would want to serialize that and the options that you have there are to serialize to a binary string or xml string and either can be sent via MSMQ.  Anyhow this is how I am currently doing this...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now