Retrieving items from a MOSS 2007 list using web services

15 April 2008

A quick code snippet to remind me how to access a list using the in built web services: 

                MOSSWebRef.Lists lists = new MOSSWebRef.Lists();
               
                lists.Credentials = new System.Net.NetworkCredential("username", "password");

                string exportList = "NameOfList";

                XmlNode node = lists.GetListItems(
                    exportList,                   
                    string.Empty,
                    null,
                    null,
                    ConfigurationManager.AppSettings["MaxRecords"].ToString(),
                    null);

                XmlTextReader xr = new XmlTextReader(node.OuterXml, XmlNodeType.Element, null);          
                string strValue = "";
                while (xr.Read())
                {
                    if (xr.ReadToFollowing("z:row"))
                    {
                         if (xr["ows_nodeName"] != null)
                        {
                           strValue = xr["ows_nodeName"].ToString();
                        }

                    }

               }

Pingbacks and trackbacks (1)+