IntroductionIn this codesnippet,explain to get list of item using web service. CodeSnippetpublic 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 |