WebHosting

Wednesday, November 16, 2011

Sharepoint Webservices : Retrieving WebSites


Retrieving WebSites

private static void readSite(string url, string login, string password)
{
    Webs service = new Webs();
    service.PreAuthenticate = true;
    service.Credentials = new System.Net.NetworkCredential(login, password);
    service.Url = url + @"/_vti_bin/webs.asmx";

    XmlNode sites = null;

    try
    {
        sites = service.GetWebCollection();
    }
    catch
    {
        return;
    }

    foreach (System.Xml.XmlNode site in sites.ChildNodes)
    {
        Console.WriteLine(site.Attributes["Url"].Value);

        GetLists(site.Attributes["Url"].Value, login, password);
        GetSites(site.Attributes["Url"].Value, login, password);
    }
}





Retrieving a WebSite List

//
//Get Web Site Lists using web service 
//
private static void getSitelists(string url, string login, string password)
{
    //List WebService 
    Lists ls = new Lists();
    ls.PreAuthenticate = true;
    ls.Credentials = new NetworkCredential(login, password);
    ls.Url = url + @"/_vti_bin/lists.asmx";

    foreach (XmlNode list in ls.GetListCollection().ChildNodes)
    {
        //Check whether list is document library
        if (Convert.ToInt32(list.Attributes["ServerTemplate"].Value) != 0x65)
        {
            continue;
        }

        string title = list.Attributes["Title"].Value;
        string listUrl = list.Attributes["DefaultViewUrl"].Value.Replace(
                                         "/Forms/AllItems.aspx", string.Empty);

        char[] separator = new char[] { '/' };
        string listPath = url.Substring(0, url.LastIndexOf('/'));

        Console.WriteLine(listPath + listUrl + "/" + title);
        AddListsItems(url, title, login, password);
    }
}




No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

How to Enable and Configure Remote Desktop (RDP) on Ubuntu 24.04.4 LTS

Remote Desktop Protocol (RDP) support in Ubuntu has become considerably easier with the GNOME Remote Desktop stack included in modern Ubuntu...