对 SharePoint 进行 SOAP 调用时引发异常

发布于 2024-12-20 00:12:53 字数 2229 浏览 0 评论 0原文

当我尝试运行我的应用程序时,我收到此异常:

抛出了“Microsoft.SharePoint.SoapServer.SoapServerException”类型的异常

我正在对 SharePoint 进行肥皂调用,并且在执行肥皂调用时它会阻塞。

下面是我正在运行的代码,有什么想法为什么会发生这种情况吗?

public string getListData()
{
   Lists myservice = new Lists();
   myservice.Credentials = System.Net.CredentialCache.DefaultCredentials;
    try
    {
        /* Assign values to pass the GetListItems method*/
        string listName = "*list name*";
        string viewName = "*view name*";
        string rowLimit = "100";
        //string successtest;
        //string failtest;

        // Instantiate an XmlDocument object
        System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
        System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
        System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
        System.Xml.XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");

        /*Use CAML query*/
        query.InnerXml = "<Where><Gt><FieldRef Name=\"ID\" />" + "<Value Type=\"Counter\">0</Value></Gt></Where>"; 
        viewFields.InnerXml = "<FieldRef Name=\"Title\" />";
        queryOptions.InnerXml = "";
        viewFields.InnerXml = "<FieldRef Name=\"Name\" />";
        queryOptions.InnerXml = "";

        System.Xml.XmlNode nodes = myservice.GetListItems(listName, viewName, query, viewFields, rowLimit, null, null);

        foreach (System.Xml.XmlNode node in nodes)
        {
            if (node.Name == "rs:data")
            {
                for (int i = 0; i < node.ChildNodes.Count; i++)
                {
                    if (node.ChildNodes[i].Name == "z:row")
                    {

                        //List<String> testList;
                        test = node.ChildNodes[i].Attributes["ows_Title"].Value;
                        //Console.WriteLine(node.ChildNodes[i].Attributes["ows_Title"].Value + "</br>");
                    }
                }
            }
        }

    }
    catch (Microsoft.SharePoint.SoapServer.SoapServerException ex)
    {
        test = ex.Detail.InnerText;
        //Console.WriteLine(ex.Message);
    }

    return test;
}

I am getting this exception when I try to run my application:

Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown

I am making a soap call to SharePoint and it is choking when the soap call is being executed.

below is the code I am running any ideas why this is happening?

public string getListData()
{
   Lists myservice = new Lists();
   myservice.Credentials = System.Net.CredentialCache.DefaultCredentials;
    try
    {
        /* Assign values to pass the GetListItems method*/
        string listName = "*list name*";
        string viewName = "*view name*";
        string rowLimit = "100";
        //string successtest;
        //string failtest;

        // Instantiate an XmlDocument object
        System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
        System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
        System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
        System.Xml.XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");

        /*Use CAML query*/
        query.InnerXml = "<Where><Gt><FieldRef Name=\"ID\" />" + "<Value Type=\"Counter\">0</Value></Gt></Where>"; 
        viewFields.InnerXml = "<FieldRef Name=\"Title\" />";
        queryOptions.InnerXml = "";
        viewFields.InnerXml = "<FieldRef Name=\"Name\" />";
        queryOptions.InnerXml = "";

        System.Xml.XmlNode nodes = myservice.GetListItems(listName, viewName, query, viewFields, rowLimit, null, null);

        foreach (System.Xml.XmlNode node in nodes)
        {
            if (node.Name == "rs:data")
            {
                for (int i = 0; i < node.ChildNodes.Count; i++)
                {
                    if (node.ChildNodes[i].Name == "z:row")
                    {

                        //List<String> testList;
                        test = node.ChildNodes[i].Attributes["ows_Title"].Value;
                        //Console.WriteLine(node.ChildNodes[i].Attributes["ows_Title"].Value + "</br>");
                    }
                }
            }
        }

    }
    catch (Microsoft.SharePoint.SoapServer.SoapServerException ex)
    {
        test = ex.Detail.InnerText;
        //Console.WriteLine(ex.Message);
    }

    return test;
}

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文