locked
Get all Folders and documents from Sharepoint Document Library using Web service RRS feed

  • Question

  • Hi All,
         My requirement is to show the whole document library structure with all the folders and documents in the asp.net page. So pls suggest me any custom web service which can bring all the structure of the Doc Lib with the document content.

    At present i am using GetListItems method of Lists.asmx. By this i could get only the document names, but not the content of the document.

    Can anyone pls suggest me the solution for this.....
    Friday, July 10, 2009 8:33 AM

Answers

  • You could get a list of documents in a document library with a link to the document, but not the content of the document, only the meta data columns.  Have you tried to specify ViewFields in the web method call?

    You could create a custom web service if the out of the box ones don't provide you with all the functionality you need.  Have a look at:

    http://msdn.microsoft.com/en-us/library/ms464040.aspx
    http://it.toolbox.com/blogs/sharepoint-blog/creating-a-custom-web-service-for-sharepoint-13553

    Inside your custom web method you could code against the SharePoint API.


    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Friday, July 10, 2009 10:42 AM
  • You can basically get what you want done using out of the box web services. I am assuming you do not want to bring all the content back per folder or per document library in a web application because this would be extremely slow. What you want to do is bring back just enough data about a folder or a document so you can navigate to each one individually within the application. You can do this by adding the "EncodedAbsUrl" field to your viewfields xmlnode in the GetListItems method. This returns the complete url to the document so then you can use to access the content and display it a custom web viewer or asp.net webpart. In order to build the whole structure of a document library including folder and subfolders you will have to make recursive call to the GetListItems method after you get the folder.  The following post shows code to get all the folders for document library. Then you can write code to get the contents of a folder when a user clicks on the folder using the GetListItems method by adding the folder name to the folder element of the QueryOptions element

    <QueryOptions><Folder>"

     

    + parentFolder + "</Folder></QueryOptions>


    http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/16a2d993-2f5e-4242-8e5a-451a78c064a3


    certdev.com
    Friday, July 10, 2009 5:30 PM

All replies

  • You could get a list of documents in a document library with a link to the document, but not the content of the document, only the meta data columns.  Have you tried to specify ViewFields in the web method call?

    You could create a custom web service if the out of the box ones don't provide you with all the functionality you need.  Have a look at:

    http://msdn.microsoft.com/en-us/library/ms464040.aspx
    http://it.toolbox.com/blogs/sharepoint-blog/creating-a-custom-web-service-for-sharepoint-13553

    Inside your custom web method you could code against the SharePoint API.


    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Friday, July 10, 2009 10:42 AM
  • You can basically get what you want done using out of the box web services. I am assuming you do not want to bring all the content back per folder or per document library in a web application because this would be extremely slow. What you want to do is bring back just enough data about a folder or a document so you can navigate to each one individually within the application. You can do this by adding the "EncodedAbsUrl" field to your viewfields xmlnode in the GetListItems method. This returns the complete url to the document so then you can use to access the content and display it a custom web viewer or asp.net webpart. In order to build the whole structure of a document library including folder and subfolders you will have to make recursive call to the GetListItems method after you get the folder.  The following post shows code to get all the folders for document library. Then you can write code to get the contents of a folder when a user clicks on the folder using the GetListItems method by adding the folder name to the folder element of the QueryOptions element

    <QueryOptions><Folder>"

     

    + parentFolder + "</Folder></QueryOptions>


    http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/16a2d993-2f5e-4242-8e5a-451a78c064a3


    certdev.com
    Friday, July 10, 2009 5:30 PM