Just another SPInsiders Sites site

I Love the SiteData.asmx Web Service

March 31, 2009 by Laura Rogers

Twitter users, you can Re-Tweet This Post.

There are a whole slew of SharePoint web services, but today I decided to try out the SiteData.asmx one, in a data view web part (the GetListCollection operation in particular).  As I’ve mentioned before, I’m not a developer, so in a lot of cases, the data view web part (DVWP) has become my best friend.

In various SharePoint discussion threads, message boards, and Q &A panels, there have been many people who have asked the following question:  How can I just display a list of my site’s document libraries in a web part?  There are varying reasons for this, such as just wanting to automatically have them all listed together somewhere other than the quick launch.  Good news!  It looks like there’s a way to do this, using the SiteData web service and the GetListCollection operation.

  1. Create a blank web part page, and open it up in SharePoint Designer.  Click on “Click here to insert a Web Part”.  This is really just to make sure that you insert this web part into a web part zone, and not some random spot on the page. 
  2. On the menu at the top, click <Insert Data View>
  3. In the Data Source Library pane on the right side, expand “XML Web Services” and click on Connect to a Web Service.
    Data Source Library
    Data Source Library
  4. Now, on the Data Source Properties screen, I always do this first, just so I don’t forget.  Go to the tab, and select Use Windows Authentication.  Of course, if you have Kerberos or some other security scenario, you’re welcome to pick something else.
  5. Now, go back over to the tab.  Copy the URL of your site to the clipboard, and paste it into the Service Description Location box.  Then, after it, type: /_vti_bin/sitedata.asmx
  6. Click <Connect Now>
  7. Leave the default Data command as Select, and for the Operation, choose GetListCollection.  As far as the Port goes, if someone knows the difference between Soap and Soap12, please let me know.

Data Source Properties
Data Source Properties

  1. Click OK
  2. Click the drop-down box on the name of the new web service (SiteData on…) and click Show Data.
  3. Now the Data Source Details task pane appears on the right, which lists all of the fields in the data source.  Select the following fields: Title, Description
    Data Source Details
    Data Source Details
  4. Click Insert Selected Fields as, and choose Multiple Item View. Now, you see a list of all lists and libraries on your site, along with their descriptions, similar to what you see on your View All Site Content page.
  5. Now, before we filter it to just show document libraries, I want to show you a couple of other things.  Click inside your list, and click the little chevron at the top right of the list, which will show you a new menu.  filterdata
  6. Click Edit Columns, and add the following columns: Inherited Security, Internal Name See how cool!  Those of you that use the URL of the list settings page to obtain the list GUID may be relieved to see this method of getting it.  Also, wow, now we can see what lists and libraries are inheriting permission from the parent or not!
  7. Just as a side note for fun, you can always click on the data in the first row of the InheritedSecurity column, and choose , and create a new condition so that if the list doesn’t inherit permission, the text is red and in all caps: columns
  8. Now, getting back to the main objective here… to display a list of document libraries.
  9. Click inside your list, and click the little chevron at the top right of the list.  Click the word Filter:
  10. The filter needs to be BaseTemplate equals DocumentLibrary.  Click OK. filtercriteria
  11. Let’s change the way that this list is displayed.  On that same list fly-out menu (or whatever the official name is), click Data View Properties…, and go to the <Layout> tab.  Choose the bulleted list of titles, and click OK. bulletedlist
  12. Now, the title of the library needs to be a link to the library itself.  Click to select the title of the first document library.  Click the little chevron next to it.
  13. In the Format As field, select Hyperlink.  Click Yes at the prompt.
  14. Clear the Address field, and click the Function box next to it.  Chose the DefaultViewURL field.  Clear the Text To Display box, and choose the Title field for that one.   Click OK. edithyperlink

There’s your pretty little list of all of the document libraries in the site!  Save the web part page, and this is what it will look like in the browser.  Export the web part, save it, and then you can delete the web part page that you created it in.  Now, import this nugget into whatever page it needs to be displayed on.

final

As I showed him all of the coolness that I discovered in web services, my (developer) co-worker said “I hate to burst your bubble, but developers already know about what’s available in the API.  This is all pretty basic stuff”.

I know, I know.  None of this is new to developers, but I’m not a developer, so I think it’s great.  It’s all new to me.  ;-)


Written by Laura Rogers

I’m currently a Senior SharePoint Consultant at SharePoint 911. I formerly worked in SharePoint in the healthcare industry for several years. I have ten years of experience with Microsoft’s messaging and collaboration systems. This includes five years in SharePoint implementation, training, and customization. I’ve been a MCSE since 1999, with my most recent certifications being MCSE 2003 + Messaging, MCTS in MOSS and MCTS in WSS 3.0 Configuration. I also wrote chapter 29 (about web parts) in the Microsoft Office SharePoint Server 2007 Administrator’s Companion.

You should follow Laura on Twitter