通过将列表名称和表单名称传递给 Web 服务,我找到了一种解决方法。然后,托管在 SharePoint 中的 Web 服务将获取表单的 XML。
这是供参考的代码:
public class InfoPathHelper
{
private string _listName;
private string _fileUrl;
public InfoPathHelper(string listName, string fileName)
{
_listName = listName;
_fileUrl = string.Format("{0}/{1}.xml", listName, fileName);
}
public string GetFormXml()
{
using (SPWeb web = SPContext.Current.Web)
{
SPList lib = web.Lists[_listName];
SPFile file = lib.RootFolder.Files[_fileUrl];
XmlDocument doc = new XmlDocument();
doc.Load(file.OpenBinaryStream());
return doc.OuterXml;
}
}
}