Search This Blog

Monday, February 9, 2015

SharePoint 2010 difference between Sever side object model and Client object model


S.No.
Sever side object model
Client object model
1.
SharePoint installation is required
SharePoint installation is not required
2.
It works with strongly with server objects
Sharepoint 2010 has provided client objects
3.
The object needs to created and access in the site collection
It can be used in .Net applications like console or any application where if it is required to item update/delete/add
4.
using Microsoft.SharePoint
It can be used
Microsoft.SharePoint.Client.Runtime.dll
Microsoft.SharePoint.Client
Silverlight.Runtime.dll

5.
SPContext
SPSite
SPWeb
SPList
SPListItem
SPField
ClientContext
Site
Web
List
ListItem
Field

                                    Share Point 2010 Client Object Model

All about Client Object Model (SharePoint)
1. Introduction to Client Object Model.
2. How Client Object Model Work?
3. Why We Use Client Object Model?
4. Example of Client Object Mode.


1. Introduction to Client Object Model.
Client Object Model is nugget feature of SharePoint 2010. It is the subset of server object model which defined in Microsoft.sharepoint.dll it is used to manipulate and consume share point data. Client object Model Implement on Window communication Foundation (WCF) service (.../_vti_bin/client.svc)

Note:

a). You Need Microsoft.sharepoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll For working with client object Model

b). Location of dll C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI

c). You Need Microsoft.SharePoint.Client. Namespace on working with client object Model

d). Client Object Model Classes are as follows

ClientContext : ClientContext class is used to context information about such objects as the current web application, site, site collection, or server version.

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.

2. 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 to the appropriate Object Model.

Client object model is WCF Web Service which is responsible for Communicating 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

3. Why We Use Client Object Model?

a). Share point installation is not required on development machine only you need to required dll’s if you are develop window application or any other application

b). Less deployment problems and client object model is very easy for end user

c) .Flexibility in language: you can use three different Language for Client object model
Microsoft .NET
Silverlight

ECMA Script (JavaScript /JScript)

d). Optimization in query speed: In Client OM, you do not need to install the SharePoint Server required by the Server Object Model. Thus Client OM provides much ease to the end user.
4. 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();
}

No comments:

Post a Comment