执行对SharePoint的SOAP调用时抛出异常

时间:2011-12-07 21:55:05

标签: c# sharepoint exception soap

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

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

我正在对SharePoint进行肥皂调用,并且在执行soap调用时它正在窒息。

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

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;
}

0 个答案:

没有答案