将整个 InfoPath 表单传递给 Web 服务(不提交)

发布于 2024-11-05 19:43:51 字数 354 浏览 6 评论 0原文

我有一个用于查询 Web 服务的 InfoPath 2010 表单。 Web 服务需要将整个 InfoPath 表单作为 XML 字符串参数。我所说的 XML 字符串是指格式上的字符串。

<my:myFields xmlns:my=...>
    <my:Name>UserName</my:Name>
    ...
</my:myFields>   

然后,Web 服务将处理该字符串并将结果返回到 InfoPath 表单。

我尝试传递根元素“.”,但在 Web 服务端我收到的值仅由 \r\n 和 \t 格式化。关于如何传递 XML 标签和值的任何想法。

I have an InfoPath 2010 form that queries a web service. The web service is expecting the entire InfoPath form as an XML string parameter. By an XML string I mean the string on the format

<my:myFields xmlns:my=...>
    <my:Name>UserName</my:Name>
    ...
</my:myFields>   

The web service will then process the string and return a result to the InfoPath form.

I have tried to pass the root element, ".", but at the web service end I am receiving the values only formatted by \r\n and \t. Any idea on how to pass the XML tags and the values.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

还如梦归 2024-11-12 19:43:51

我找到了一种解决方法,将列表名称和表单名称传递给 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;
        }
    }
}

I have found a workaround by passing the list name and the form name to a web service. The web service, which is hosted in SharePoint, will then get the XML of the form.

Here is the code for reference:

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;
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文