Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send XML to MSMQ without <string> wrapper

Status
Not open for further replies.

supermatchgame

Programmer
May 16, 2007
50
GB
I have written some code that sends the XML from an XMLDocument into an MSMQ message. The message arrives at the queue fine but for some reason the format of the message is:

Code:
<?xml version="1.0"?><string>my xml.. </string>

This is causing problems because my middleware engine is expecting the XML without the string wrapper and is refusing to process the message.

Can anyone please tell me if it's possible to send data to MSMQ without this <string></string> wrapper getting appended or if I need to approach this differently?

Thanks!
 
xml requires a root node, so if you want to turn
Code:
<?xml version="1.0"?><string>my xml.. </string>
into
Code:
<?xml version="1.0"?>my xml..
then technically you are not passing xml to the service, only text.
the simplest solution is to get the inner text of the xml document's root node
Code:
var doc = new XmlDocument();
doc.Load(...);
var text = doc.InnerXml;
//send text to service;
it's been awhile since I worked with with raw xml, so I am probably off with member names of XmlDocument, but the idea is there.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top