locked
"Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown." RRS feed

  • Question

  • I get the following error when I run this code... Can someone help me as to what this error means ? I am very new at Sharepoint and SOAP and I cannot seem to find this error out on the web :(

    ex = {"Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."}

    _COMPlusExceptionCode = -532459699

     

     public partial class DocLibraryList : System.Web.UI.Page
    
        {
    
            protected void Page_Load(object sender, EventArgs e)
    
            {
    
                GetLists("http://smacesptw", "gbeford", "Spring02");
    
            }
    
    
    
            //Get Web Site Lists  
    
            private void GetLists(string url, string login, string password)
    
            {
    
                //List WebService 
    
    
    
                // create list
    
                Lists ls = new Lists();
    
                //When PreAuthenticate is true, the WWW-authenticate header 
    
                //is sent with all subsequent requests.
    
                ls.PreAuthenticate = true;
    
             
    
    
    
                //Authenticate the current user by passing their default 
    
                //credentials to the Web service from the system credential 
    
                //cache.
    
                ls.Credentials = new NetworkCredential(login, password);
    
    
    
                //Set the Url property of the service for the path to a subsite. 
    
                //Not setting this property will return the lists in the root Web site.
    
                ls.Url = url + @"/_vti_bin/lists.asmx";
    
    
    
                //Declare an XmlNode object and initialize it with the XML 
    
                //response from the GetListCollection method.
    
                //Loop through XML response and parse out the value of the
    
                //Title attribute for each list. 
    
                foreach (XmlNode list in ls.GetListCollection().ChildNodes)
    
                {
    
                    //Check whether list is document library
    
                    if (Convert.ToInt32(list.Attributes["ServerTemplate"].Value) != 0x65)
    
                    {
    
                        continue;
    
                    }
    
    
    
                    string title = list.Attributes["Title"].Value;
    
                    if (title == "Company Shared Documents")
    
                    {
    
                        string listUrl = list.Attributes["DefaultViewUrl"].Value.Replace("/Forms/AllItems.aspx", string.Empty);
    
    
    
                        char[] separator = new char[] { '/' };
    
                        string listPath = url.Substring(0, url.LastIndexOf('/'));
    
    
    
                        lblOutput.Text += listPath + listUrl + "/" + title + "<br/>";
    
                        AddListsItems(url, title, login, password);
    
                    }
    
                }
    
            }
    
    
    
    private void AddListsItems(string url, string listName, string login, string password)
    
            {
    
                Lists ls = new Lists();
    
                ls.PreAuthenticate = true;
    
                ls.Credentials = new NetworkCredential(login, password);
    
                ls.Url = url + @"/_vti_bin/lists.asmx";
    
    
    
                XmlTextReader reader = null;
    
                DataSet dataSet = null;
    
    
    
                //Try to get List Items
    
                try
    
                {
    
                    XmlNode rez = ls.GetListItems(listName, null, null, null, null, null, string.Empty);
    
                    reader = new XmlTextReader(rez.OuterXml, XmlNodeType.Element, null);
    
                }
    
                catch
    
                {
    
                }
    
    
    
                dataSet = new DataSet();
    
                dataSet.ReadXml(reader);
    
                if (dataSet.Tables["row"] != null)
    
                {
    
                    foreach (DataRow row in dataSet.Tables["row"].Rows)
    
                    {
    
                        string title = row["ows_LinkFilename"].ToString();
    
                        string listPath = row["ows_FileRef"].ToString();
    
                        char[] separator = new char[] { '#' };
    
                        listPath = listPath.Split(separator)[1].ToString();
    
                        separator = new char[] { '/' };
    
                        listPath = url.Split(separator)[0].ToString() + "//" + url.Split(separator)[2].ToString() + "/" + listPath;
    
    
    
                        string documentType = string.Empty;
    
                        try
    
                        {
    
                            documentType = row["ows_DocIcon"].ToString();
    
                        }
    
                        catch
    
                        {
    
                            documentType = string.Empty;
    
                        }
    
    
    
                        Console.WriteLine(listPath);
    
                        if (documentType.Length > 0)
    
                        {
    
                            //This is a file Link
    
                        }
    
                        else
    
                        {
    
                            //This is a folder
    
                            AddSubFolderContent(url, listName, title, login, password);
    
                        }
    
                    }
    
                }
    
            }
    
    
    
            /// <summary>
    
            /// Add SubFloder Content to a node
    
            /// </summary>
    
            /// <param name="url">URL</param>
    
            /// <param name="docLibName">docLib Name for WebService Call</param>
    
            private void AddSubFolderContent(string url, string listName, string docLibName, string login, string password)
    
            {
    
                string name = string.Empty;
    
                XmlNode nodes = null;
    
                XmlNode ndQueryOptions = null;
    
                XmlDocument xmlDoc = null;
    
                XmlTextReader xmlTextReader = null;
    
                DataSet dataSet = null;
    
    
    
                try
    
                {
    
                    Lists ls = new Lists();
    
                    ls.PreAuthenticate = true;
    
                    ls.Credentials = new NetworkCredential(login, password);
    
                    ls.Url = url + @"/_vti_bin/lists.asmx";
    
    
    
                    //Preaparing XML Query
    
                    xmlDoc = new System.Xml.XmlDocument();
    
                    ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
    
                    string TheQuery = listName + "/" + docLibName;
    
                    if (TheQuery[0].ToString() == "/")
    
                    {
    
                        TheQuery = TheQuery.Substring(1);
    
                    }
    
                    ndQueryOptions.InnerXml = "<Folder>" + TheQuery + "</Folder>";
    
    
    
    
    
                    nodes = ls.GetListItems(listName, null, null, null, null, ndQueryOptions, null);
    
                    xmlTextReader = new XmlTextReader(nodes.OuterXml, XmlNodeType.Element, null);
    
    
    
                    dataSet = new DataSet();
    
                    dataSet.ReadXml(xmlTextReader);
    
    
    
                    if (dataSet.Tables["row"] != null)
    
                    {
    
                        foreach (DataRow sn in dataSet.Tables["row"].Rows)
    
                        {
    
                            name = sn["ows_LinkFilename"].ToString();
    
                            string objectUrl = sn["ows_FileRef"].ToString();
    
                            char[] separator = new char[] { '#' };
    
                            objectUrl = objectUrl.Split(separator)[1].ToString();
    
                            separator = new char[] { '/' };
    
                            objectUrl = url.Split(separator)[0].ToString() + "//" + url.Split(separator)[2].ToString() + "/" + objectUrl;
    
    
    
                            string TypeItem = string.Empty;
    
                            try
    
                            {
    
                                TypeItem = sn["ows_DocIcon"].ToString();
    
                            }
    
                            catch
    
                            {
    
                                TypeItem = string.Empty;
    
                            }
    
    
    
                            Console.WriteLine(objectUrl);
    
                            if (TypeItem.Length > 0)
    
                            {
    
                                //This is a file Link   
    
                            }
    
                            else
    
                            {
    
                                //This is a folder                         
    
                                AddSubFolderContent(url, name, docLibName + "/" + name, login, password);
    
                            }
    
                        }
    
                    }
    
                }
    
                catch (Exception ex)
    
                {
    
                }
    
                finally
    
                {
    
                }
    
            }
    • Edited by Mike Walsh FIN Tuesday, March 30, 2010 5:37 AM Actual error code specified in Title. (Original: "help with error code")
    • Moved by Mike Walsh FIN Tuesday, March 30, 2010 5:37 AM Code question (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Monday, March 29, 2010 6:58 PM

Answers

  • When you get the generic soap exception you can read the error details with:

     

    catch (Microsoft.SharePoint.SoapServer.SoapServerException ex)

    {

    Console.WriteLine(ex.Detail.InnerText)

    }

    Tuesday, March 30, 2010 9:06 AM

All replies

  • A few things to consider before I can make any hints

     

    Where your error is thrown? I Assume it will be


    foreach (XmlNodeList list in ls.GetListCollecton().ChildNodes)

     

    right? So the rest of your code would be unnecssary here. Not everyone here has the time to look over masss of code so it would have increased your chance of an answer.

     

    I don't bevlieve it is a good idea to iterate through a collection that is each time retrieved when looping through, so

    XmlNode lists = ls.GetListCollection()

    foreach (XmlNodeList list in lists.ChildNodes)

     

    should be a much better alternative, exspecially in regard to the performance.

     

    Another point:

    ls.Credentials = new NetworkCredential(login, password);


     

    Are you sure you don't have to use the domain of the user? The Credential's constructor is overloaded so try also giving it the domainname and try again.

     

     

    regards,

    Markus

    Tuesday, March 30, 2010 7:32 AM
  • A few things to consider before I can make any hints

     

    Where your error is thrown? I Assume it will be


    foreach (XmlNodeList list in ls.GetListCollecton().ChildNodes)

     

    right? So the rest of your code would be unnecssary here. Not everyone here has the time to look over masses of code so think it would have increased your chance of an answer.

     

    I don't believe it is a good idea to iterate through a collection that is each time retrieved when looping through, so

    XmlNode lists = ls.GetListCollection()

    foreach (XmlNodeList list in lists.ChildNodes)

     

    should be a much better alternative, ecspecially in regard to the performance.

     

    Another point:

    ls.Credentials = new NetworkCredential(login, password);

     

    Are you sure you don't have to use the domain of the user? The NetworkCredential's constructor is overloaded so try also giving it the domainname and try again.

     

     

    regards,

    Markus

    Tuesday, March 30, 2010 7:32 AM
  • Agree with Markus, seeing such a huge chunk of code itself puts me off from looking in depths trying to figure out a solution.

    Could you let me know what is your business scenario like what are you trying to achieve using Lists.asmx?


    BR, PM
    Tuesday, March 30, 2010 8:07 AM
  • When you get the generic soap exception you can read the error details with:

     

    catch (Microsoft.SharePoint.SoapServer.SoapServerException ex)

    {

    Console.WriteLine(ex.Detail.InnerText)

    }

    Tuesday, March 30, 2010 9:06 AM
  • Piero, I'm 99% certain the stacktrace will begin at
    GetLists(...)
    Tuesday, March 30, 2010 10:24 AM
  • thank you all for the help :)
    Wednesday, March 31, 2010 3:49 PM