SharePoint 2010 Client Object Model
If you want to access SharePoint Server 2007 Data, you have two ways of doing it (based on your needs):
1. Writing a Server Application
This application resides in server
2. Writing a Client Application
This client application can run from any other server or a desktop
Server Application
We interact with the Server Object Model, which are nothing but SharePoint APIs and build applications.
For example:
List<Announcement> announcements = new List<Announcement>();
SPSite site = SPContext.GetContext(HttpContext.Current).Site;
using (SPWeb curWeb = site.OpenWeb())
{
SPList lstAnnouncements = curWeb.Lists[new Guid(LibraryName)];
//rest of the code
}
Client Application
We use the SharePoint Web Services which then interacts with the SharePoint API. Usually, developers either build their own set of web services which exposes only certain methods/functions they want to expose to the application or consume the default out of the box SharePoint web services. This becomes difficult if you are going write rich client applications such as Silverlight, or Javascript applications.
The Future of SharePoint Client Applications:
SharePoint 2010 introduces the new Client Object Model. From the sneak peak videos:
“The Client Object Model (OM) is a new programming interface for SharePoint 2010 where code runs on a user’s client machine against a local object model and interacts with data on the SharePoint Server. Client OM methods can be called from JavaScript, .NET code or Silverlight code and makes building rich client applications for SharePoint easy.”
One API to rule them all – Yep, whether its WPF or Windows Forms or Silverlight or Javascript – your code uses Client Object Model to interact with the SharePoint site to access the data. Now, there is something common that everybody can use instead of creating their own wrapper services to access SharePoint data!
What is Client Object Model?
Client Object Model is introduced in SharePoint 2010 which helps to developers to make things easier to develop the client side applications for SharePoint 2010. Client Object Model can run on the client machines (Where SharePoint is not installed) and communicate with the SharePoint server remotely. This is the great advantage for the SharePoint devs as they don't have to install SharePoint for development any more.
What are the different Client OM supporting in the SharePoint 2010 API? [Client API]
1. .NET Managed Client - Implemented in .NET CLR. I mean we use this in Web, Windows and Console applications.
2. Silverlight Client - You can use the SharePoint objects in Silver light coding. Wow, this is going to be a huge advantage to the Silverlight applications which can be integrated into SharePoint. Before we don't have access to SharePoint objects inside Silverlight context.
3. ECMAScript Client - Through javascript too, we can get context and do manipulations to SharePoint objects. Do you think it's possible? Yes, its a brilliant way of thinking from Microsoft SharePoint team and this will help in great scenarios.
SharePoint object model syntax:
| Server side syntax | Client side syntax |
|---|---|
| SPContext | ClientContext |
| SPSite | Site |
| SPWeb | Web |
| SPList | List |
SharePoint 2010 provides the client support files to refer the SharePoint objects and communicate with the SharePoint server. Below are the details.
| ForManaged Client | DLL's needed : Microsoft.SharePoint.Client.dll, Microsoft.SharePoint.Client.Runtime.dll. Find these files in the 14/ISAPI folder. Usually, the location would be at "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI". |
| Silverlight | Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll. They find at "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin". |
| ECMAScript | SP.js file - The file fund at "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS". |
Very good post Rama.
ReplyDelete