Tuesday 8 May 2012

Sharepoint 2010 Client Object Model - Part 1

Last week one of my colleague took a session for all of us to explain the Client Object Model in Sharepoint 2010, so i thought to share the knowledge via this blog article.

What is Client Object Model (COM)
Client Object Model (Client OM) is a unified model which can be used by developers to access the server. The Client OM can be accessed via web services, via a client (JavaScript) API, and via REST. Microsoft SharePoint 2010 introduces three new client APIs that allow you to interact with SharePoint sites from script that executes in the browser, from code that executes in a .NET managed application, or from code that executes in a Microsoft Silverlight 2.0 application.

Key Points one should know about the COM:
  1. There are limitations to what can be done client side compared to server side, say for example you cannot access the FARM level properties, you can get/set only the properties at the web application level.
  2. we cannot elevate the privilege in COM as we can do in server object model.
  3. No SharePoint installation is required in the development machine.Only  the Client DLL's are required.
  4. No Compilation required as required on the server side, NO IISRESET required.
  5. Path to get DLL's: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI

The following table shows the equivalent objects that the new APIs provide for common SharePoint Foundation 2010 server objects.

Server Object Model .Net Managed & Silverlight JavaScript
SPContext ClientContext SP.ClientContext
SPSite Site SP.Site
SPWeb Web SP.Web
SPSite.Title Site.Title SP.Site.get_title() & SP.Site.set_title()

Client Object Model Mechanics
Below mentioned diagram explains the architecture of the Client Object Model in Sharepoint 2010
Image Reference is here
  • Client Object Model is a façade on top of WCF service.
  • Requests for the resources are batched using Load & LoadQuery methods.
  • Requests are executed using ExecuteQuery or ExecuteQueryAsync methods.
    • XML document with batched request information is sent to server.
    • JSON response with requested resources is sent back to the client.
In our subsequent articles we will describe how to implement each of the COM using different client.

I Hope this article was informative. Happy Sharepointing !

Please do Share/Like/Comment if this article was helpful.

1 comment: