When I call my webservice, it only returns the string “System.Xml.XmlDocument” rather than the actual XML. What do I need to change to get it to return an actual XML document?
public XmlDocument GetCommoditiesXmlDocument() {
XmlDocument xdoc = new XmlDocument();
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
//gets XML as XmlElement
quotes.WriteTo(xtw);
xdoc.LoadXml(sw.ToString());
return xdoc;
}
I’m using .NET 4.0 (and MVC3 if it matters)
ASP.Net MVC does not know how to serialize an
XmlDocumentinto an HTTP response.Instead, you should return the XML source directly: