Friday 1 June 2012

Webservice to get data form sharepoint list


Below is the Sample Code to get the data form SharePoint List using Web Services

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Xml;


namespace SharepointWebService
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    public class Service1 : System.Web.Services.WebService
    {
        [WebMethod]
       
        public XmlNode NewExtentians()
        {

            WS_Lists.Lists lists = new WS_Lists.Lists();
            System.Net.NetworkCredential cred = new System.Net.NetworkCredential(username,password);
            string rowLimit = "5";
            lists.Credentials = cred;
            XmlNode n = lists.GetListItems("Listname", null, null, null, null, null, null);
            return n;
        }
    }
}

--
Done :)

No comments:

Post a Comment