Get ListItems with there columns of a specific SharePoint List
using the SharePoint Webservice Lists.asmx .
private XmlNode GetSiteListItems(string sSiteUrl, string sSiteList)
{
WS_Lists.Lists list = new WS_Lists.Lists();
list.Url = sSiteUrl + "/_vti_bin/lists.asmx";
if (bDefaultLogon)
list.Credentials = System.Net.CredentialCache.DefaultCredentials;
else
{
list.PreAuthenticate = true;
list.Credentials = new System.Net.NetworkCredential(sTechnicalUser, sTechnicalPw, sDomain);
}
Console.WriteLine(sSpaces + "Start GetSiteListItems " + sSiteList + " " + sSiteList + "...");
string rowLimit = "99999";
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode listQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode listViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
listViewFields.InnerXml = "<FieldRef Name=\"Title\">" +
"<FieldRef Name=\"INTERNAL_FIELDNAME1\"></FieldRef>" +
"<FieldRef Name=\"INTERNAL_FIELDNAME2\"></FieldRef>" +
"<FieldRef Name=\"INTERNAL_FIELDNAME3\"></FieldRef>" +
"<FieldRef Name=\"INTERNAL_FIELDNAME4\"></FieldRef>" +
"<FieldRef Name=\"INTERNAL_FIELDNAME5\"></FieldRef>" +
"<FieldRef Name=\"INTERNAL_FIELDNAME6\"></FieldRef>" ;
XmlNode listQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
XmlNode ndListItems = null;
try
{
ndListItems = list.GetListItems(sSiteList, null, listQuery, listViewFields, rowLimit, listQueryOptions, null);
}
catch (Exception e)
{
Console.WriteLine(sSpaces + "Error GetSiteListItems {0}", e.Message);
}
finally
{
list.Dispose();
Console.WriteLine(sSpaces + "End GetSiteListItems " + sSiteList + " " + sSiteList);
}
return ndListItems;
}
Geen opmerkingen:
Een reactie posten