RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


SharePoint Applied: SharePoint 2007 with WCF and Silverlight

Innovative solutions sometimes require multiple ingredients. Find out how to mix it up with SharePoint, WCF, and Silverlight.

ilverlight 2 just went RTM. This product is unique because for the first time in the Microsoft world, you have .NET running cross platform, in a secure way, and without all the deployment hassles. It has the ability to bring rich UI, right to the browser—much like Flash, but with more capabilities and a .NET heart.

So, what does this mean to you as a SharePoint developer? Well, as I elucidated in my previous article, developing rich UIs in SharePoint 2007 isn't exactly my idea of a good time! In fact, it is a bit like a three-year old playing drums on your head all night long while his seven-year old sister is sticking chewing gum in your hair as you are trying to sleep because you have an early morning 7:00 AM morning meeting in a recessionary economy. Take heart! The thin .NET 3.5 development model makes it all easier.

In this article, I will illustrate an example that builds a Silverlight front-end to SharePoint functionality. The Silverlight control will work within the SharePoint context, and will thus allow you to access the SharePoint object model from the restricted Silverlight CLR. Throughout this article, I will focus on illustrating the specific development steps I follow to make my development of Rich UIs within SharePoint a whole lot easier. Let's begin with defining the problem first.

Problem Definition

I find the calendar list in SharePoint quite useful. In this article, I will build a Silverlight UI that shows me appointments for today while remaining under the current user's context. These appointments will be stored in the calendar list and will be rendered in a rich Silverlight UI. At the very onset, this seems to tell me that the Silverlight UI running inside SharePoint would need to have full access to the SharePoint context. How in the world would I achieve that in the restricted Silverlight CLR?

In order to achieve this, I will need to write:

  1. A Silverlight .xap file. I will have to work with Visual Studio 2008 SP1 (with Silverlight tools installed), and Expression Blend 2 SP1 to craft this UI.
  2. A WCF service. This service will work in-context, retrieving the appointments under the security context of the currently logged-in user. The Silverlight UI will consume the service using basicHttpBinding.
  3. A contract. This contract specifies how the Silverlight application will talk to the WCF service. This is the same as the WCF contract.
The first step is to define the WCF contract, shown below:

   public interface IAppointments
      List GetAppointments();
In the preceding code, BO.Appointment is a custom business object defined as follows:

   public class Appointment
      public DateTime AppointmentTime { 
         get; set; }
      public string Title { get; set; }
With the contract defined, you can write up the pieces around the contract.

Editor's Note: This article was first published in the March/April 2009 issue of CoDe Magazine, and is reprinted here by permission.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date