Using an XmlDocument Returned from a WebService

Sir Google was kind to me tonight. In a web service I’m working on, I’m returning a relatively simple xml stream to the calling client (in this case, of type System.Xml.XmlDocument). I got it all figured out/debugged, built a test client to test it, and promptly realized that the client was seeing the return type from the web method as type System.Xml.XmlNode. Since XmlDocument inherits from XmlNode, downtype casts aren’t allowed.

The above article explains a workaround relatively nicely. Perhaps there’s an easier way to accomplish this though.

No comments yet