Nevin Mathai
Nevin Mathai

Reputation: 2396

Read an XML file in a WCF service and return XML from the service

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

Answers (1)

Marc Gravell
Marc Gravell

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

Related Questions