1

I'm trying to retrieve list items for my "Country" list through web services.

This is my list: http://i.stack.imgur.com/158MI.png

& this is my code:

using System.Linq;
using System.Text;
using System.Net;
using System.Xml;

namespace SPwebservices
{
    class Program
    {
        static void Main(string[] args)
        {
            SPlistservices.Lists client = new SPlistservices.Lists();
            client.Credentials = new NetworkCredential("****", "******");

            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
            XmlNode viewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
            XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");

            viewFields.InnerXml = "<FieldRef Name=\"Title\" />" +
                "<FieldRef Name=\"AgentName\" />" +
                "<FieldRef Name=\"AgentNumber\" />";


            XmlNode listItems = client.GetListItems("Country", null, ndQuery, viewFields, null, ndQueryOptions, null);

                foreach (XmlNode node in listItems)
                    if (node.Name == "rs:data")
                        for (int f = 0; f < node.ChildNodes.Count; f++)
                        {
                            if (node.ChildNodes[f].Name == "z:row")
                            {
                                string title = node.ChildNodes[f].Attributes["ows_Title"].Value;
                                string agentName = node.ChildNodes[f].Attributes["ows_AgentName"].Value;
                                string agentNumber = node.ChildNodes[f].Attributes["ows_AgentNumber"].Value;

                                Console.WriteLine(title + " " + agentName + " " + agentNumber);
                            }
                        }   
                 Console.ReadKey(false);
        }
    }
}

Unfortunately I get this exception:

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

"List does not exist.The page you selected contains a list that does not exist. It may have been deleted by another user."

pointing at:

XmlNode listItems = client.GetListItems("Country", null, ndQuery, viewFields, null, ndQueryOptions, null);

Does anyone have a clue, what's wrong?

I got this from a tutorial so its very difficult for me to debug it..

  • did you check with fiddler and/or soapUI? maybe you have to many items – Salvatore Di Fazio Apr 9 '13 at 10:10
  • if you see this error may be uncurrect list or view ID – user35523 Nov 27 '14 at 2:33
  • Any you get a final solution? For me, the signature for GetListItems method is public System.Xml.Linq.XElement GetListItems(string listName, string viewName, System.Xml.Linq.XElement query, System.Xml.Linq.XElement viewFields, string rowLimit, System.Xml.Linq.XElement queryOptions, string webID) It use XElement, not XmlElement neither XmlNOde. And I get the same error about it. – Kiquenet Mar 16 '15 at 8:22
1

Webservice reference points to the root site. And I am guessing list does not exists in root site. Is your list URL looks like following:

http://yoursite/WEB/lists/Country

If yes then above code is searching list in 'yoursite' and not in 'WEB' Check this link: Accessing subsites' lists via the MOSS 2007 Lists.asmx web service

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

check the above line and check this link may it helps you.

http://sarangasl.blogspot.in/2009/12/sharepoint-list-web-service.html

  • Thanks for this! Its a nice example. I'll give it try separately and see if the exception persists over there.. – lephleg Apr 9 '13 at 11:03
  • Sorry @Robert Kaucher, I think I dropped this after a couple of days trying. Its been a while though.. – lephleg May 13 '14 at 13:47
0

Please, Check if the WebReference that you created has the property "Web Reference URL" something like: http://topLevelSite.yourdomain.br/sites/yourTestSite/_vti_bin/Lists.asmx.

In my case, i was reference it for a wrong URL. After i just right it, the excpetion is gone way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.