Why can't an XmlDocument be passed via remoting?

  • Thread starter Thread starter William
  • Start date Start date
W

William

I don't get it? Of all things, shouldn't an XmlDocument type be serializable
by default? How can I pass this type through a remoting service?

It just doesn't make sense, especially since DataSets can be passed, which
are XML.
 
William said:
I don't get it? Of all things, shouldn't an XmlDocument type be
serializable by default? How can I pass this type through a remoting
service?
It just doesn't make sense, especially since DataSets can be passed, which
are XML.

Don't know, but it is trivial to take an XmlDocument to a string, which can
be passed via remoting.
 
William,

I would have thought the same thing. However, it's easy to work around.
Just return a string.

I know it's not optimal, but it will work.

You could always load the XmlDocument into a DataSet and then return
that if you want to expose an object.

Hope this helps.
 
You can put you XML into dataset and pass it like this:

private DataSet GetUserData()

{

// Set the path of the XML file and XML schema.

string strPath = Server.MapPath(".");

// Declare a data set.

DataSet dsUsers = new DataSet();

// Apply the XML schema to data set.

dsUsers.ReadXmlSchema(strPath + "\\UserInfo.xsd");

// Read the XML into the data set.

dsUsers.ReadXml(strPath + "\\UserInfo.xml");

return dsUsers;

}

chanmm
 
Thank you.

Actually, what I wound up doing is something like this:

[WebMethod]
public XmlDocument Order(XmlDocument doc)
{
IOrder rObj = (IOrder)Activator.GetObject(typeof(IOrderCert),
ConfigurationManager.AppSettings["PocRemotingServer"]);
string ret = rObj.Order(doc.InnerXml);
XmlDocument retxml = new XmlDocument();
retxml.InnerXml = ret;
return retxml;
}

On the remote server side, I rebuild the XmlDocument and consume it in the
Business Logic Layer, which expects and XmlDocuement.

All a bit hokey and I am at a loss to explain why Microsoft decided to make
such an obvious task a bit of a hassle.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top