Wednesday, August 10, 2005 4:03 PM bart

SharePoint Web Services - Obtain a collection of lists

Since a couple of weeks now I'm involved in a SharePoint development project for a local company based in Belgium. Dedicated to this topic, I've create a post category called "IW stuff - Office, SharePoint, IBF" where I'll post some useful information in. Today I'll kick off with a very simple piece of code to obtain a collection of the lists on a Windows SharePoint Services site using the SharePoint Web Services.

First of all, if you've not done so yet, please download the SharePoint Products and Technologies 2003 SDK over here. This API contains a single chm file called spptsdk.chm with a lot of documentation in it. You'll certainly find this useful (I, as a SharePoint development newbie, do).

SharePoint provides a series of web services that can be used to interact with a SharePoint-driven website for administration and management tasks. I grabbed the following table directly from the API:

Service Description
Administration Provides methods for managing a deployment ofWindows SharePoint Services, such as for creating or deleting sites.
Alerts Provides methods for working with alerts for list items in a SharePoint site.
Document Workspace Exposes the Document Workspace Web service and its eleven methods for managing Document Workspace sites and the data they contain.
Forms Provides methods for returning forms used in the user interface when working with the contents of a list.
Imaging Provides methods that enable you to create and manage picture libraries.
List Data Retrieval Provides a method for performing queries against lists in Microsoft Windows SharePoint Services.
Lists Provides methods for working with lists and list data.
Meetings Provides methods that enable you to create and manage Meeting Workspace sites.
Permissions Provides methods for working with the permissions for a site or list.
Site Data Provides methods that return metadata or list data from sites or lists in Microsoft Windows SharePoint Services.
Sites Provides a method for returning information about the site templates for a site collection.
Users and Groups Provides methods for working with users, site groups, and cross-site groups.
Versions Provides methods for working with file versions.
Views Provides methods for working with views of lists.
Web Part Pages Provides the methods to send information to and retrieve information from XML Web services.
Webs Provides methods for working with sites and subsites.

As I'm currently interested in the Lists stuff, I'll focus on this in this first SharePoint-related post. On my development machine, I created a http://sharepointdev website for all of my experiments. The web services can be found in the _vti_bin folder which is actually a virtual directory to the %programfiles%\Common Files\Microsoft Shared\Web Server Extensions\60\isapi folder on your system. You won't find very useful information in the .asmx files over there, as these are just stubs for a code-behind implementation, but it's nice to know where these files physically reside on the system. Now, go to Visual Studio .NET and add a Web Reference to http://sharepointdev/_vti_bin/Lists.asmx (well, do substitute the host part of the URL as needed of course). Over here, I'm using a Windows Forms C# project to visualize the data as a first test. The following code assumes there is a DataGrid control on the form (Dock = Fill) named "dataGrid1":

//Create the proxy object
sharepointdev.Lists l = new

//Integrated Windows authentication credentials
l.Credentials = CredentialCache.DefaultCredentials;

//Query the service for a collection of lists
XmlNode node = l.GetListCollection();

//Create a reader to populate a DataSet
XmlTextReader r = new XmlTextReader(node.OuterXml, XmlNodeType.Document, null

//Create a DataSet and populate it using the constructed XmlReader
DataSet ds = new

//For sake of demo, just bind the DataSet's first (and only) table to a DataGrid control
dataGrid1.DataSource = ds.Tables[0];

What this does is pretty basic: it just populates a DataSet with information about the lists on the SharePoint website. Not so exciting but nevertheless pretty cool as a first SharePoint Web Services development adventures sample. I already have some nice ideas to interact with SharePoint through these services. Check out my "IW stuff - Office, SharePoint, IBF" blog post category regularly to keep on track! | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Filed under:


# re: SharePoint Web Services - Obtain a collection of lists

Tuesday, August 30, 2005 1:09 PM by bart

Why Sharepoint ? Use DotNetNuke instead.