I needed to use GetListItems of web service Lists.asmx, to get all aspx pages in Pages library.
However, I saw, that I needed to pass the WebId as parameter to GetListItems. So I added another reference to SiteData.asmx.

Below, is the code to get The WebId, need to add reference to Lists.asmx here, webPath is the url of the sarepoint site.

private Guid GetWebID(string webPath)
{

SiteDataWebService.SiteData siteDataWS = new SiteDataWebService.SiteData();

siteDataWS.UseDefaultCredentials = true;

SiteDataWebService._sWebMetadata webMetaData;

SiteDataWebService._sWebWithTime[] arrWebWithTime;

SiteDataWebService._sListWithTime[] arrListWithTime;

SiteDataWebService._sFPUrl[] arrUrls;

string roles; string[] roleUsers; string[] roleGroups;

siteDataWS.Url = webPath + “/_vti_bin/sitedata.asmx”;

siteDataWS.Credentials = new NetworkCredential(username, password, domain);

uint i = siteDataWS.GetWeb(out webMetaData, out arrWebWithTime, out arrListWithTime, out arrUrls, out roles, out roleUsers, out roleGroups);

Guid gid = new Guid(webMetaData.WebID);

return gid;
}

The code to access GetListItems is shown below:

private System.Xml.XmlNode GetItems(string webPath)

{

ListsOnLocalhost.Lists listsWS = new Sharepoint_Unit_Tests.ListsOnLocalhost.Lists();

listsWS.Url = webPath + “/_vti_bin/lists.asmx”;

listsWS.UseDefaultCredentials = true;

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

doc.LoadXml(“”);

System.Xml.XmlNode listQuery = doc.SelectSingleNode(“//Query”);

System.Xml.XmlNode listViewFields = doc.SelectSingleNode(“//ViewFields”);

System.Xml.XmlNode listQueryOptions = doc.SelectSingleNode(“//QueryOptions”);

Guid gid = GetWebID(webPath);

System.Xml.XmlNode items = listsWS.GetListItems(listName.Text, string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, gid.ToString());

return items;

}

Advertisements