Welcome to my blog, stay tunned :


REST is heavily used in SOA architectures. All the posts tagged with REST refer to using REST inside of SharePoint 2010 and 2007.

Building and consuming a custom oData service for SharePoint 2010

For a recent project, I’ve been involved together with another fellow SharePoint developer Jeroen Van Bastelaere (http://www.skavi.be) in optimizing a SharePoint portal application.
The first idea we had was to use caching, so we built a lightweight caching framework that is flexible and maintainable enough and that allowed us to reach our main objective which was gaining performance.
I tell you this little story because the topic of this post is actually inherited from the above context. Thus, still having the performance objective in mind, we’ve also been asked to build asynchroneous controls (webparts, user controls…) for user friendlyness and fast initial page loads.
Of course, one could have chosen a common approach which is to make use of jQuery together with ListData.svc/Lists.asmx or involve the ECMAScript COM and that might have been ok but…I prefered to consume our data from our caching system to make sure this would be the most performant approach (server side at least).
At first, I thought of simply writing a REST service using the built-in SharePoint MultipleBaseAddressWebServiceHostFactory . That could have paid the bill but I wanted something very flexible in terms of query engine so I ended up in building a custom oData service that consumes our cached data.
One of the main cached object we dealt with is User Profiles. For scalability and performance reasons, we decided to get all the user profiles via a search query, cache them during the entire day since they get synchronized only once a day, and then, target this cache for any subsequent User Profile query. Our business scenario allowed us to cache them an entire day.

That works very well and prevents also the system from overloading the User Profiles store with thousands of connections. This is threfore not only more performant but also more robust.

That said, the example I will show you in this post demonstrates how to consume that User Profile cache with a custom oData service.
The advantage of oData is its ability to build rich RESTFUL Urls and also to be able to consume it from a server-side control just like we do with ListData.svc.
So, I’ll cover the following topics in this article:

  • Building a the cache framework (basic subset of what we’ve done to avoid unnecessary complexity)
  • Building a CachedData.svc service that will for this example expose oData operations on the cached User Profiles (this could of course be extended to any kind of data)
  • Consume it with jQuery
  • Consume it from a Console Application


ADO.NET Data Services must be installed on the system, you can download it from there :

Creating the project

  • Create an empty SharePoint 2010 Project
  • Add the following references :



Building the cache framework

As said before, this light framework enables storing data in cache very easily. It’s made of a few classes, I’ve removed most of its complexity in order to have something as understandable as possible since this is not the main topic of this post.
I’ve also hard-coded some values and removed exception handling for sake of simplicity.
First, the interface that defines what any cached member should implement:

public interface ISharePointData<T>
        List<T> GetItems();              
        int CacheDurationInSeconds { get; set; }
        int CacheDurationInMinutes { get; set; }
        int CacheDurationInHours { get; set; }        

Here, the contract specifies that any member should implement a GetItems() method and the time to be set in cache before expiration.

Using the SharePoint RESTful service listdata.svc from within a custom Document Information Panel


I've just recorded a new video that was published on Channel9, if you're interested to watch it, it's here:


Happy coding!

using jQuery with ListData.svc and redirecting the user when not logged in using FBA


When querying ListData.svc directly from AJAX, if your SharePoint web application is configured using Windows Authentication with either NTLM or Kerberos, your browser will either transmit your credentials automatically (Internet Explorer), either will prompt you to let you logging in (other than IE).

This behavior is not similar when trying to perform AJAX queries in FBA mode, so when your SharePoint web app is set up to use FBA combined to CBA.

In that case, the following piece of code:

would branch to the error part in case you're not yet authenticated. To handle that, you can redirect the user to the regular SharePoint login page so that he gets this:

To handle that, you can use a piece of code looking like this one:

where you test the returned status which is 302 with Firefox & 12150 with IE 8 for some reason...In case this error is returned, you just redirect the user by building the new URL dynamically. SharePoint will do the remainder and the user will be redirected back to the current page after authentication gets complete.

What I presented at the BIWUG

Warning: I've just (on Sun. may 16) re-amended the code to be compatible with the RTM.
Today, after a trafic jam session (thanks Vilvoorde...) because of which I got late, I presented a session on how WCF is integrated into SharePoint 2010 beta2 (I've not tested yet on the RTM bits) and more particularly how you can benefit from the RESTFUL services and more particularly from ListData.svc.

BIWUG Videos published

Hi All,

My session on SPLINQ has been published on Channel 9 at http://channel9.msdn.com/posts/katriendg/BIWUG-session-LINQ-to-SharePoint/. You can watch the other sessions at http://channel9.msdn.com/posts/katriendg.

Happy coding!

Querying, Updating data using a WCF reference to ListData.svc from a console program


Here are the steps to process to get started with the OOTB WCF ListData service.

- Create a web site with two lists, let's say Customers and Cities. Populate those lists with a few entries. The Customers list should contain a column named City that's a lookup to the Cities list.

- Create a new console (or whatever...) program and add a reference to the WCF service this way:

Beta 2 - Getting WCF ListData.svc project reference to work with SharePoint 2010

Hi All,

I've recently digged into the new WCF services of SharePoint 2010 and discovered some troubles with it. If you follow the steps mentioned on the following URL:

http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/21/introduction-to-querying-lists-with-rest-and-listdata-svc-in-sharepoint-2010.aspx , you'll notice that reproducing his example works fine.

WCF REST Like services and SharePoint


If you're interested by this topic, I just published a new article on Developpez.com, here it is http://stephaneey.developpez.com/tutoriel/sharepoint/spwcfrest/