Reputation: 2396
I need to read an XML file in my WCF service and return the same file as XML back from my WCF service in C#. Can someone point me to the right direction. Most samples out there seems outdated.
Upvotes: 2
Views: 6079
Reputation: 1062484
I believe you can just return XmlElement
(for example, the root element) and it'll work?
[OperationContract]
XmlElement GetXml(string path);
...
public XmlElement GetXml(string path) {
var doc = new XmlDocument();
doc.Load(path); // TODO: add security...
return doc.DocumentElement;
}
Upvotes: 3