Consume SharePoint WebServices with Console Application

SharePoint can be used for a variety of different purposes. Most of the time it’s part of a bigger solution/infrastucture. If that’s the case, soon you will find yourself wanting to use SharePoint data in other applications. There are several ways of getting data out of SharePoint, we will be looking at the OOTB shipped SharePoint Webservices.

  1. First we want to create a new console application,
    Open Visual Studio and go to File → New → Project.
  2. We now want to create a new Service Reference to our SharePoint site, right click your newly created project and choose “Add Service Reference”
  3. Its time to get our hands dirty and write some code, HiHaahh
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using SharePointWebServiceDemo.SPListWS;
    using System.Xml.Linq;
    namespace SharePointWebServiceDemo
        class Program
            static void Main(string[] args)
                using (ListsSoapClient proxy = new ListsSoapClient())
                    proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                    proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                    XElement spLists = proxy.GetListCollection();
                    foreach (XElement el in spLists.Descendants())
                        foreach (XAttribute attrib in el.Attributes())
                            System.Console.WriteLine("> " + attrib.Name + " = " + attrib.Value);
  4. Last, but not least, we edit our app.config

    <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />


    <security mode="TransportCredentialOnly">
      <transport clientCredentialType="Ntlm"/>

Credits: Bin Yu

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s