473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

I'm trying to send and receive XmlDocument objects using the
System.Messaging.dll functions. The code I've written follows, as best I
can tell, the methodology used in the sample code for the
XmlMessageFormatter class. But it isn't working -- specifically, receiving
isn't working. What am I doing wrong here?

I begin by creating a MessageQueue object and setting up its
XmlMessageFormatter to handle XmlDocument objects:

System.Type[] types = { System.Type.GetType("XmlDocument") };
XmlMessageFormatter fmt = new XmlMessageFormatter(types);
queue = new MessageQueue(queueName);
queue.Formatter = fmt;

I can then use the queue object to send XmlDocument messages with no
problem:

XmlDocument doc = new XmlDocument();
doc.LoadXml("<msg/>");
doc.DocumentElement.SetAttribute("time", String.Format("{0}",
DateTime.Now));
queue.Send(doc);

But receiving these messages doesn't work:

Message msg = queue.Receive(TimeSpan.Zero);
XmlDocument doc = (XmlDocument) msg.Body;

throws this exception:

An unhandled exception of type 'System.ArgumentNullException' occurred
in mscorlib.dll
Additional information: Key cannot be null.

I can readily work around this problem. I just need to set up the
XmlMessageFormatter object to handle String objects instead of XmlDocument
objects. Then on sending, I send the doc.OuterXml property, and I receive
with this code:

Message msg = queue.Receive(TimeSpan.Zero);
XmlDocument doc = new XmlDocument();
doc.LoadXml((string) msg.Body);

But I'd sure like to know why the code I've written doesn't work.

Bob Rossney
rb*@well.com
Nov 12 '05 #1
4 4826
Hi Robert,

We have reviewed your post. We will do some research on your issue and will
reply to you ASAP.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #2
Hi Robert!

Thanks for using the Microsoft Newsgroups. Carl Huber is one of our
support team members and will be replying to your issue ASAP. He is
currently investigating your problem. In the meantime, if you have any
questions, please feel free to reply to me and I will help you as best I
can.

Brett Keown
Microsoft Support
br*****@online.microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 12 '05 #3
Hi Robert,

I've done some research on this issue and so far it appears the problem is
that the XMLDocument object is not marked as serializable. I haven't
confirmed this yet but I'm pretty sure that's the reason.

I'll let you know for sure when I have more information. Hope this helps.

Regards,
Carl Huber, MCSD
Microsoft Developer Support/Visual Basic WebData
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! -> http://www.microsoft.com/security

Nov 12 '05 #4
Hi Robert,

I just wanted to let you know I'm still researching the issue. As soon as
I have more information, I will post it.

Regards,
Carl Huber, MCSD
Microsoft Developer Support/Visual Basic WebData
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! -> http://www.microsoft.com/security

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Pete Loveall | last post by:
I have a server application that monitors a private local queue for messages. The message sent to it has a label and a response queue defined. It works correctly when the queue is accessed via...
1
by: **** KiteOregon **** | last post by:
I need to send & receive XML Document Objects via the Message Queue. We have several applications that insert XML Document Object into the message queue. This works with no problem. I am trying...
0
by: **** KiteOregon **** | last post by:
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...
0
by: Stefan Näsman | last post by:
Hi I have a problem receiving messages from Message Queue when the message is a XMLDocument. When a have received it and tries to read it it says that there is no root element. Do onyone...
6
by: Tom | last post by:
I try to write a simple tcp based job queue server. It's purpose is to get commands from a client and store them in a queue (STL). The server has a thread which checks periodically the queue,...
2
by: Richard A. Wells | last post by:
All I wanted to do was implement a web service where I'd receive an XML document and return one in response. I'd already figured out how to use XmlReader and XmlWriter classes to do the XML work I...
2
by: SammyBar | last post by:
Hi all, I'm trying to send a message from ASP.NET to another PC by using MSMQ. I created my ASP.NET project by using Visual Studio 2005 but I initially set the project to be located on the File...
0
by: neonspark | last post by:
I'm buidling some simple macro functionality for my app so the users can record a sequence of keyboard inputs and replay them reliably via some menu. Originally, I used: protected override bool...
1
by: =?Utf-8?B?UnVp?= | last post by:
Can I override the send and receive methods on a web service proxy? I want to use the default proxy classes generated when I add a reference to a web service to create and read the SOAP messages...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.