SharePoint 2010 - Web Services

SharePoint Web Services provides us a good feature that allows us to access or change the SharePoint items remotely. We can use the Web Services to add more power to our application.

The following are the core features of SharePoint Web Services:

  • Foundation and Server Web Services
  • More Interoperability compared with Server Object Model
  • Above 25 Web Services
  • Manage Sites, Lists, Libraries, and Picture Libraries etc.
  • Run queries against the server
  • Custom Web Service creation possible

The following table contains some of the web services inside SharePoint 2010:





Creation and Deletion of sites



List Management service



List Item Events service



Authentication based service



Web sites management service



Searching service


A more detailed list can be found here:

How to find the URL of a Service?

The URL of a service can be located in the _vti_bin folder of the site or site collection. Each site or site collection will have this folder with all the web services inside it with a .asmx extension.

Example: To use the search service use the following URL:



Using http://appes-pc/_vti_bin/Lists.asmx


Adding Reference to Project

Now we can try adding a reference to the service inside the Visual Studio application. Create a new Ordinary Console Application (please note that we are not using a SharePoint Console Application):


Now we need to Add a Web Reference. In Visual Studio 2010 this option is available under the Add Service Reference option as shown below:


In the dialog that appears click the Advanced button.


In the next dialog, choose the Add Web Reference option.


You will get the following dialog. This dialog is suitable for adding web service references.


Enter the URL of the Lists.asmx as shown above. You need to replace the PC name with yours.

Set a Web reference name in the second highlighted box. This serves as the namespace.

Click the Add Reference button and your proxy class and related classes will be ready within a while. Inside the Program.cs, enter the namespace and you can see the classes inside it as shown below:


Invoking the Proxy Class

Our class of interest is the Lists proxy. You can create an instance of it using the following code:

SPReference.Lists client = new SPReference.Lists();

Setting Credentials

Whenever we open a SharePoint site (without anonymous login enabled) the site will prompt with user credentials. As we are invoking through a web service the prompt dialog won't work. We need to pass the credentials using the property named Credentials.

client.Credentials = new NetworkCredential("appes", "password"); / // using System.Net;

Getting a Reference to a List

We can try getting a reference to the Manager List inside our site. The Managers list contains items with columns:

  • Title
  • Name
  • Address


Use the following code to fetch the data and display it to the console:

SPReference.Lists client = new SPReference.Lists();
client.Credentials = new NetworkCredential("appes", "PWD");
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
viewFields.InnerXml = "<FieldRef Name=\"Title\" />" +
    "<FieldRef Name=\"Name\" />" +
    "<FieldRef Name=\"Address\" />";

XmlNode listItems = client.GetListItems("Manager", null, null, viewFields, null, null, 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 name = node.ChildNodes[f].Attributes["ows_Name"].Value;
                string address = node.ChildNodes[f].Attributes["ows_Address"].Value;

                Console.WriteLine(title + " " + name + " " + address);


On executing the application we can see the following result:


The following are the steps involved in getting list item data:

  1. Create List Proxy client

  2. Set Credentials

  3. Set the View Columns

  4. Invoke GetListItems() method

  5. Iterate through the nodes

  6. Get value of node having name z:row


Using web services, XML is used to represent the data. For advanced programming using properties, please refer to the Server Object Model and SharePoint LINQ articles.



In this article we have seen the Web Services feature of SharePoint 2010. It provides the flexibility of interoperability compared with the Server Object Model. Developers can access and manage a SharePoint site from non .Net platforms like Java. The attached source code contains the example we discussed.