Archive

Archive for the ‘Web Services’ Category

Using Web Services To Display Lists and Views

May 21st, 2011 Abed Khooli No comments

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.

Categories: Lists, SharePoint Designer 2010, Views, Web Parts, Web Services Tags: DataForm,

Lists And Views – Hidden And Visible

May 19th, 2011 Abed Khooli No comments

You may want to hide a list from the browser and the first thing you would do is to remove it from the quick launch. But, any one who can see All Site Content will find it easily. This is what SharePoint Designer is good at. Open the site in SPD, go to Lists and Libraries (from Site Objects), select your list and on the properties page, uncheck Show in Quick Launch and check Hide from Browsers. This way, the list will not show even if you try with All Site Content. You can still view the list if you know the url, of course, bit you can’t make it visible from the browser (trying to set it to show in Quick Launch will not stick and you need to go back to SharePoint Designer to undo the change).
For views, you can actually set the Hidden=”TRUE” property once you edit the view page in SPD (the <View Name=”" Type=”" source element). Hidden views are normally associated with web parts. If you turn a normal view (say you went to your list and created a new view) into hidden, you can’t see it even with SharePoint Designer on the properties page of the list. You can, however, ask a web service and sure, you will see hidden lists and views. In fact, SPD uses services to communicate with the SharePoint server.
In the illustration, I connected two xslt views (web parts) together. The first has all the lists in a given site and the second displays the views of the selected list.
Notice that the services retrieves many interesting properties for our lists – those funny GUIDs, item count, default view … etc. You can get some of these from the browser (all site content will give you list item count and you can spot list GUID in the URL), but this view looks handy.
Notice that this may expose some sensitive information, so you should keep the page you use to display this stuff away from public (ex. use special permissions).The services used here are the Lists.asmx and Views.asmx (the old web services). Notice that the ListData.svc does not see External lists (asmx service only sees what the browser does – it reports zero for item count). The actual setup of data sources and web part connection may be the subject of another post.

Categories: Lists, SharePoint Designer 2010, Views, Web Services Tags: Hidden Lists, Hidden Views, Lists.asmx, Views.asmx

SharePoint 2010 Data Services

April 30th, 2011 Abed Khooli No comments

You can still access and use the old ASP.NET (.asmx) web  services in SharePoint 2010. These are used, mostly, to access SharePoint data remotely as in remote admin, for bulk operations, and – of course – for backward compatibility. Their use is not encouraged as of the 2010 version especially as a replacement of the server side object model (in code) or when a better option exists or can be built.
The new data service is REST compatible and based on the Open Data protocol. It uses the normal HTTP requests and is called the WCF (Windows Communication Foundation) service.
You can see the available lists at a certain site by browsing to http://site-address/_vti_bin/listdata.svc where an XML file is displayed showing available site lists. It should be noticed, however, that spaces are ignored in list and library titles, so “my great list” becomes mygreatlist.
You can access the data of a certain list by appending the list title (no spaces) to the above URL, so http://site-address/_vti_bin/listdata.svc/TeamTasks will retrieve all items of the Team Tasks list in XML format (TeamTasks is the List Title here). You can get a specific item by specifying its ID – ex.  http://site-address/_vti_bin/listdata.svc/TeamTasks(3) for the item with ID = 3 or http://teams/test/_vti_bin/listdata.svc/TeamTasks(3)/Title to get, only, the title of that item. You can even make queries with filters like http://site-address/_vti_bin/listdata.svc/TeamTasks?$filter=StatusValue eq ‘Completed’ which filters completed tasks in a task list (notice that StatusValue is used here as this is the actual title of the Status column in task lists).

You can do other filtering and sorting and also other operations (in addition to retrieve aka GET). These are POST (create), PUT (Update all fields), MERGE (Update specific fields) and DELETE (Delete). There is more at Using REST Interface.
If you receive an error like “could not load type ..” when you try to access the available lists, you will need this Data Service Update (Win 7 and 2008 R2).