在WCF服务读取XML文件,并从服务返回的XML [英] Read an XML file in a WCF service and return XML from the service
本文介绍了在WCF服务读取XML文件,并从服务返回的XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要读取XML文件在我的WCF服务和XML从我的WCF服务在C#中返回相同的文件回来。可有人点我到正确的方向。大多数样品在那里似乎已经过时。
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.
推荐答案
我相信你可以只返回的XmlElement
(例如,根元素),它会工作的?
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;
}
这篇关于在WCF服务读取XML文件,并从服务返回的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文