SharePoint 2010 provides 3 new client-side object models: Managed, Silverlight and JavaScript. It provides libraries for each and they are located in the below locations.
Each client object model interacts with SharePoint through a Windows Communication Foundation (WCF)
Managed Object Model
|
Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.ClientRuntime.dll
|
ISAPI folder
|
Silverlight client object model
|
Microsoft.SharePoint.Client.Silverlight.dll
Microsoft.SharePoint.Client.Silverlight.Runtime.dll
|
LAYOUTS\ClientBin folder
|
JavaScript client object model
|
SP.js
|
LAYOUTS folder
|
Each client object model interacts with SharePoint through a Windows Communication Foundation (WCF)
service named Client.svc, which is located in the ISAPI directory. Every request sent as a single Extensible Markup Language (XML) request to the Client.svc service. The results of the server-side calls are then sent back to the calling client in the form of a JavaScript Object Notation (JSON) object.
Here is a code sample:
Server object model
|
Managed Model
|
Silverlight Model
|
Javascript Model
|
SPContext
|
ClientContext
|
ClientContext
|
ClientContext
|
SPSite
|
Site
|
Site
|
Site
|
SPWeb
|
Web
|
Web
|
Web
|
SPList
|
List
|
List
|
List
|
SPListItem
|
ListItem
|
ListItem
|
ListItem
|
SPField
|
Field
|
Field
|
Field
|
Here is a code sample:
//Server Object Model
SPSite siteCollection = SPContext.Current.Site;
string siteCollectionURL= siteCollection.Url;
//Managed Client Object Model
using (ClientContext clientContext = new ClientContext("Site URL"))
{
Site siteCollection = clientContext.Site;
clientContext.Load(siteCollection);
clientContext.ExecuteQuery();
string siteCollectionURL = siteCollection.Url;
}
//Silverlight Client Object Model
using (ClientContext clientContext = new ClientContext("Site URL"))
{
Site siteCollection = clientContext.Site;
clientContext.Load(siteCollection);
clientContext.ExecuteQuery();
string siteCollectionURL = siteCollection.Url;
}
//JavaScript Client Object Model
var siteCollection;
function getSiteCollection
{
var clientContext = new SP.ClientContext("/");
siteCollection = clientContext.get_site;
clientContext.load(site);
clientContext.executeQueryAsync(success, failure);
}
function success {
string siteCollectionURL = siteCollection.get_url;
}
function failure {
alert("Failure!");