Do not use on any
shared computer
August 29, 2008 10:07pm pdt
 
[x]
Attachment Details

Microsoft.SharePoint.SoapServer.SoapServerException was thrown

Tags: type, exception
Hi

I try to get listitem from Sharepoint, and I receive this message

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

This is my code. I have a reference to my Sharepoint Server and I work on my localhost on my work computer.

I have a problem with this line of code after de command try:
System.Xml.XmlNode nodeListItems = listService.GetListItems(listName, viewName, ndQuery, ndViewFields, rowLimit, ndQueryOptions);

Thanks for your help
 
[WebMethod]
            public string GetItemList(string sListName)
            {
                  string sReturn="";
                  
                  WindowsPrincipal p =(WindowsPrincipal)HttpContext.Current.User;
                  
                  WindowsIdentity id = (WindowsIdentity)p.Identity;

                  //Response.Output.Write("<h2>Process running as {0}</h2>",
                  //WindowsIdentity.GetCurrent().Name);

                  // impersonate temporarily
                  WindowsImpersonationContext wic = id.Impersonate();

                  
                  // Declare and initialize a variable for the Lists Web Service.
                  SharepointList.Lists listService = new SharepointList.Lists();

                  // Set the Url property of the service for the path to a subsite.
                  listService.Url = "https://intranet.2020.net/_vti_bin/Lists.asmx";
                  
                  /* Authenticate the current user by passing their default
                  credentials to the Web Service from the system credential cache.*/
                  listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
                  
                  // Instantiate an XmlDocument object
                  System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();

                  /* Assign values to the string parameters of the GetListItems method,
                  using GUIDs for the listName and viewName variables*/
                  string listName = "{17991794-81BB-494F-9910-CFBF1093A7CF}";
                  string viewName = "{7137FFF8-48FF-4C69-8C76-0E3BBD1EA7F9}";
                  string rowLimit = "150";
                  

                  /*Use the CreateElement method of the document object to create elements
                  for the parameters that use XML*/
                  System.Xml.XmlElement ndQuery = xmlDoc.CreateElement("Query");
                  System.Xml.XmlElement ndViewFields = xmlDoc.CreateElement("ViewFields");
                  System.Xml.XmlElement ndQueryOptions = xmlDoc.CreateElement("QueryOptions");

                  /*To specify values for the parameter elements (optional), assign CAML fragments
                  to the InnerXml property of each element*/
                  ndQuery.InnerXml = "<Where><Gt><FieldRef Name=\"ID\" />" +
                        "<Value Type=\"Counter\">3</Value></Gt></Where>";
                  ndViewFields.InnerXml = "<FieldRef Name=\"Title\" />";
                  ndQueryOptions.InnerXml = "";

                  /* Declare an XmlNode object and initialize it with the XML response from
                  the GetListItems method.*/
                  
                  try
                  {
                        System.Xml.XmlNode nodeListItems = listService.GetListItems(listName, viewName, ndQuery, ndViewFields, rowLimit, ndQueryOptions);

                        // Loop through each node in the XML response and display each item.
                        foreach (System.Xml.XmlNode listItem in nodeListItems)
                        {
                              sReturn += listItem.OuterXml;
                        }
                  }
                  catch(Exception e)
                  {
                        sReturn = e.Message;
                  }
                  finally
                  {
                        wic.Undo();
                  }
                  
                  return sReturn;

            }
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Software
Question Asked By: piec2
Solution Provided By: Prestaul
Participating Experts: 1
Solution Grade: A
Views: 96
Translate:
Loading Advertisement...
 
[+][-]Accepted Solution by Prestaul
Accepted Solution by Prestaul:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Administrative Comment by Venabili
Administrative Comment by Venabili:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Administrative Comment by Computer101
Administrative Comment by Computer101:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34