Saturday, June 14, 2014

SharePoint 2013 - Client Object Model

Client Object Model is a subset of the SharePoint Server Object Model and consists of rich set of libraries for client side data access.

Why Client Object Model?
1) Prior to SharePoint 2010 only the out of box SharePoint web services could be used for client side data access.
2) Web services uses soap and difficult to manage using client scripts.
3) Client Object Model API is more closer to Server Object Model.
4) Most of the methods and properties in Server Object Model exists in Client Object Model too. 

Client Object Model - Implementation 
There are 3 different ways to implement client object model.
1) The .NET Client Side Object Model (CSOM) :- Based on .Net managed assemblies mainly Microsoft.SharePoint.client.dll and  Microsoft.SharePoint.client.Runtime.dll which are located in 15\ISAPI

2) Silverlight Client Object Model :- Used to integrate Silverlight applications with SharePoint. The assemblies Microsoft.SharePoint.Silverlight.client.dll and  Microsoft.SharePoint.client.Silverlight.Runtime.dll that support Silverlight object model are located in 15\TEMPLATE\LAYOUTS\ClientBin

3) JavaScript Object Model (JSOM) :- Consists of set of JS files for enabling client side access using ECMAScript (JavaScript, JScript). The main JS files SP.js, SP.Core.js and SP.Runtime.js are located in 15\TEMPLATE\LAYOUTS\ and downloaded when the referring pages are opened in browser.

Client Object Model - Architecture
The Client Object Model supports multiple platforms like .NET, JavaScript and Silverlight. All these platforms consume a WCF service named Client.svc which is published under the /_vti_bin/ folder of the current site. The client object model accepts REST requests as well as XML requests and responds with JSON or XML Atom responses.

Following picture will give you a complete overview of the the Client Object Model architecture.

Client Object Model - Advantages
1) Silverlight and ECMAScript applications can access the SharePoint data from the client side browser itself.
2) Web parts with rich user interface can be developed with the help of Silverlight and jQuery.
3) JSOM can be implemented with just a Content Editor Web part within the browser or from the SharePoint designer without opening the Visual Studio.
4) When we save your site as a template. The application developed with ECMAScript or Silverlight application implemented with Client Object Model would come along with the template which would be very helpful during migrations though we need to take care of any hard coded values.
5) No IISREST is required while deploying a Silverlight or an ECMAScript application implemented with COM.
6) We can have SharePoint accessed from the client desktop using Windows forms or WPF applications implemented with COM.
7) No SharePoint installation is required in the development machine. Only the dll’s are required if you are going to develop Silverlight applications.

Client Object Model - Limitations
1) Admin Tasks Restrictions:- Client Object Model cannot be used for admin tasks like working with web applications and farms. It can only be used with sites, sub-sites, list, libraries and web parts.
2) No Elevated privileges or Impersonation:- Elevated privileges or Impersonate are not applicable in client object model since the data retrieved is already security trimmed by default.
3) Some Classes Missing:- There is also a constraint on classes available for data access. For instance, there are no classes for accessing user profile data, though it is available in web services.
4) Data access across multiple site collections prohibited:- The objects in another site collection cannot be access while implementing in Silverlight or in an ECMAScript (to avoid client side scripting). If we try, an error will be thrown stating "The security validation for this page is invalid."
5) Recurring events fails in Calender list:- Recurring events cannot be retrieved from a SharePoint calendar list using Client Object Model.

In the next post we will see the demo for all the different methods for implementing client object model.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.