How to use the GetListItems web service

The following two functions can be used after adding references to Lists.asmx and SiteData.asmx
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(“<Document><Query /><ViewFields /><QueryOptions /></Document>”);
System.Xml.XmlNode listQuery = doc.SelectSingleNode(“//Query”);
System.Xml.XmlNode listViewFields = doc.SelectSingleNode(“//ViewFields”);
System.Xml.XmlNode listQueryOptions = doc.SelectSingleNode(“//QueryOptions”);
Guid g = GetWebID(webPath);
System.Xml.XmlNode items = listsWS.GetListItems(listName.Text, string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, g.ToString());

return items;

}

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”;
uint i = siteDataWS.GetWeb(out webMetaData, out arrWebWithTime, out arrListWithTime, out arrUrls, out roles, out roleUsers, out roleGroups);
Guid g = new Guid(webMetaData.WebID);

return g;

}