1
votes

I have to read Shared Documents from all sites/subsites of Sharepoint in my Console application which will run on the same machine where Sharepoint is installed but it will be based on .Net Framework 4.0. I believe, Sharepoint Server Objects is based on Framework 3.5 so I came up with idea to create my custom web service which read and return list of documents. I created my custom Service as mentiond in this blog and it is working fine. Here is my code to read the documents in one of my web service method.

SPWebApplication webApp = SPContext.Current.Site.WebApplication;
            #region Traverse all sub sites
            foreach (SPSite subSite in webApp.Sites)
            {
                using (SPWeb sWeb = subSite.OpenWeb())
                {
            foreach (SPList list in sWeb.Lists)
            {
                if (list.BaseType == SPBaseType.DocumentLibrary &&
                                    list.Hidden == false && list.BaseTemplate == SPListTemplateType.DocumentLibrary &&
                                    list.Title.Equals("Style Library", StringComparison.InvariantCultureIgnoreCase) == false &&
                                    list.Title.Equals("Site Assets", StringComparison.InvariantCultureIgnoreCase) == false)

But as soon as I reach on following line "foreach (SPList list in sWeb.Lists)" it throw exception of type "'System.Threading.ThreadAbortException'"

Even if I try to get the Lists count above this foreach loop sWeb.Lists.count, it still throw the same exception. Please help me what I am doing wrong here?

1
doesn't the out-of-the-box web services do what you want ?Steve B
Also, you should ask on sharepoint.stackexchange.comSteve B
Steve, what do you mean by "out-of-the-bod web services"? You mean the services which is builten in Sharepoint foundation?user1455675
How can I access all subsites by giving root site URL using this service. Please note that I need to read docuements from all sites/subsites. I will appreciate if you can give me any idea or sample code.user1455675

1 Answers

0
votes

Check out the SharePoint Client Object Model. It provides an easy way to call SharePoint web services. Using the Server Object Model in a client application is tricky and does not provide a good authentication technique. I believe your problem is with authentication since you cannot setup credentials for the Server Object Model.