By: admin

Developers Corner July 16, 2014 Last Updated: July 16, 2014


 

Introduction to Client Object Model

 

Client Object Model is the newest feature of SharePoint 2010. It is the subset of server object model which the Microsoft has defined as Microsoft.sharepoint.dll. The primary function is to manipulate and consume share point data. Client Object Model Implement on Window communication Foundation (WCF) service (…/_vti_bin/client.svc)

 

Note:


1. To work on Client Object Model, you need Microsoft.sharepoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll
2. Location of dll will be as follows:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI
3. You Need Microsoft.SharePoint.Client. Namespace on working with client object Model

 

Client Object Model is classified into different classes which are as follows –

 

ClientContext: ClientContext class is used to context information about such objects as site, site collection.
Site: Site class is used to get the site collection.

Web: Web class is used to get the web on current site collection.

List: List is used to get the list.
ListItem: ListItem class is used to get the ListItem.

 

 

How Client Object Model Work?

 

The Client OM send request as an XML format and server will return a JSON (java script Object Notation) which is converted into the appropriate Object Model.
This could be illustrated with the help of the following diagram. It is an easier way to access SharePoint 2010 data using Client Object Model –

 

 

How Client Object Model Work?
Client.svc:

 

Client object model is basically a WCF Web Service which is responsible for communication between client Object Model and Share Point Data. Client.svc is located along with all other SharePoint Web Services. The response from Client.svc Web Service is sent as JSON format.

 

Client.SVC service has one method (ProcessQuery ) which takes SteramObject
ProcessQuery method found in Microsoft.SharePoint.Client.ServerRuntime.dll and private class ClientRequestServiceImpl
Location of client.svc service: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Client.SVC

 

 

Why We Use Client Object Model?

 

1. Share Point installation is not required on development machine. If you want to develop a window application or any other application, you only require dll’s.

 

2. Client Object Model is user-friendly as it poses less deployment problems.


3. Flexibility in language: You can use any of the three different languages for Client Object Model


Microsoft .NET
Silverlight
ECMA Script (JavaScript /JScript)

 

4. Optimization in query speed: In Client OM, you do not need to install the SharePoint Server which is required by the Server Object Model. Thus, Client OM provides much ease to the end user.

 

 

Example of Client Object Model

 

//Method Add items into list
private void AddNewListItem()
{
var: clientContext = new ClientContext(“your site URL/”);
var :list = clientContext.Web.Lists.GetByTitle(“ListName”);

var: param = new ListItemCreationInformation();

var :newItem = list.AddItem(param);
newItem[“Title”] = “This my new announcement”;
newItem[“Body”] = “This is the body of announcement”;
newItem.Update();

clientContext.ExecuteQuery();
}

 

Posted by-

Deepak Chauhan 

 

 

Disclaimer: Developer’s Corner Section of ISHIR blog is contributed and maintained by independent developers. The content herein is not necessarily validated by ISHIR.

 

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *