I am thinking about posting a few entries on how we would go about consuming SharePoint data. There are many options out there. I’ll start with the good old web services way. Using SharePoint ASMX web services will allow you to consume List and Site Data as well as do many administrative tasks, such as creating sites and pages to web part and list management.
Reference to v3.0 and MOSS 2007 web services – http://msdn.microsoft.com/en-us/library/bb862916(office.12).aspx
Scenario – View all lists and libraries on a SharePoint site using the Lists web service [http://wsssite/_vti_bin/Lists.asmx]
I’ve got a WPF desktop application with a single Page. This page will need to have a TAB control. One of its Tabs will need to list all available SharePoint Lists and Libraries on a given site.
Solution – Overall approach and steps
Step One – Firstly, assuming you’ve got all that you need. A WSS 3.0 or a MOSS 2007 site with some lists and libraries. By default you should have some. You also got Visual Studio and a WPF Desktop application built. You go ahead and add a web service reference to the Lists ASMX service mentioned above. Go a step further and define a class that will eventually hold your List data.
Here’s a code snippet to a WPF Tab Control with one Tab in it.
Step Two – Secondly, we start in the code behind. We’ll need few things. I went ahead and defined a class to hold my List Data. Here it is.
Step Three – Thirdly make sure you’ve got your web service referenced and such. Let’s add some code to call on it during the WPF page initialization and loading.
In addition to service reference, you will need references to LINQ and Threading.
Step Four – Wire it up and load the list of all libraries available on the site
Notice the use of Threading and Asynchronous calls into the web service. Why, well, simply put so the WPF UI doesn’t get stuck on the call to the web service and you could load the Tab control without affecting the user experience.
Step Five – Code the actual work to be done
Summary – This is just one option of how to consume SharePoint data in your client application. Next time I’ll try to demonstrate how to do that using SharePoint 2010 Client Object Model.
Take it easy.