GetListItem using sharepoint webservice

No.of Views1374
Bookmarked0 times
Downloads 
Votes0
By  trushar82   On  09 Apr 2010 10:04:37
Tag : SharePoint , How to
How to get list of item in sharepoint with webservice
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

In this codesnippet,explain to get list of item using web service.

CodeSnippet

public System.Data.DataSet GetListItem(string UserName, string Password, string Domain, string SiteURL, string ListName, string nodeQuery, Guid SiteGuid)
{
DataSet dsList = new DataSet();
try
{
ListData.Lists list = new ListData.Lists();
list.Url = SiteURL + "/_vti_bin/lists.asmx";
list.Credentials = new System.Net.NetworkCredential(UserName, Password, Domain);
list.PreAuthenticate = true;
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlNode ndQuery = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "Query", "");

//ndQuery.InnerXml = "";
ndQuery.InnerXml =nodeQuery;
System.Xml.XmlNode ndViewFields = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "ViewFields", "");
System.Xml.XmlNode ndQueryOptions = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, "QueryOptions", "");
System.Xml.XmlNode items = list.GetListItems(ListName, string.Empty, ndQuery, ndViewFields, "", ndQueryOptions, SiteGuid.ToString());

System.IO.StringReader sr = new System.IO.StringReader(items.OuterXml.ToString());
dsList.ReadXml(sr);
return dsList;
}
catch (Exception)
{

}
return dsList;
}

Thank you

 
Sign Up to vote for this article
 
About Author
 
trushar82
Occupation-Software Engineer
Company-www.allscripts.com
Member Type-Fresh
Location-India
Joined date-02 Nov 2009
Home Page-
Blog Page-http://sharepointdata.blogspot.com
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top