Using Web Services To Display Lists and Views
In the previous post, I talked about hidden lists and views and how you can use a web service to surface a number of list and view properties. In this post, I will outline the actual steps involved.
First, we will define two data sources in SharePoint Designer 2010 based on the SOAP Service connection: open the specific site in SPD, from the site objects navigation, select Data Sources. From the ribbon tab (data sources) select SOAP service connection. Provide a name on the General tab of the dialog and an optional description (we will call it Lists) and leave the Login tab as is. In the sources, enter http://site-address/_vti_bin/Lists.asmx?WSDL
Click the Connect button and select the GetListCollection item from the Operations drop down. Click OK to close the dialog.
Create a web part page and insert a data view based on the Lists source (Insert – Data View and find Lists under the SOAP Services category). We need to do this now as we will need to get a list id to initialize the second data source. Make sure the Name column is displayed (use add/remove columns if needed) and copy one of the names (including the curly brackets). Keep this for the next step.
Next, create another SOAP source and call it Views with address: http://site-address/_vti_bin/Views.asmx?WSDL and in the Operation drop down, select GetViewCollection. You’ll notice that it requires a parameter called ListName. Highlight the row and click Modify. Paste the Name you copied earlier in the default value box and check the box “the value of this parameter ..). Click OK twice to save the Views source.
Back on the web part page, add another data view based on the Views SOAP source. You should see one or more views belonging to the list you selected. Now, we need to connect the two web parts.
Select the Views web part and click Add Connection (from the ribbon) and select Get Parameters From on the first screen and click Next. Click Next on teh second screen and also on the third one (should have Lists and Send Row Data to). In the next screen, you are asked to match a field from the Lists web part to the ListName parameter. The item on the left reads “none”. Click it to select Name from the drop down and click Next. Keep Title as the hyperlink and check Indicate Current Selection Using, from the options (click modify) select ID from key columns. Click Next then Finish. Save your page and test it. Once you click a list title, its views are displayed and the title becomes bold. You can add/remove columns from either the Lists and Views dataform web parts and also control column order. Be sure to hide or block this page from unauthorized users. Notice that, unlike a REST service, a SOAP service can see the external list but it won’t report its item count (it shows 0). Although asmx services are on their way to retire, they can still be handy for several scenarios.