Understanding Client Object Model Fundamentals

The client object model introduced as part of SharePoint 2010 enables users to build solutions that can consume SharePoint data and objects from applications that do not run on a SharePoint server. These applications can be anything ranging from simple websites using AJAX/Silverlight to Windows Presentation Foundation (WPF) applications. You can use the client object model for developing the following:

• .NET applications

• ECMAScript client

• Silverlight applications

• WPF applications

There are three different client object models:

• Managed model

• JavaScript model

• Silverlight model

This hour covers the first two models. A separate hour, Hour 9, “Creating Silverlight User Interfaces for SharePoint 2010 Solutions,” is dedicated to Silverlight integration with SharePoint 2010.

Figure 8.1 shows the architecture of the client object model.

Image

Figure 8.1. Client object model architecture

The architecture for enabling communication between the client object model and the SharePoint content database is provided through a WCF service called Client.svc located in the ISAPI directory. The client object model batches the operations as an XML request and calls the Client.svc. Once the XML request from the client is received, Client.svc uses the server object model to retrieve relevant information from the SharePoint content database, and the results obtained are returned to the client as JavaScript Object Notation (JSON).

The client object model is actually a set of several different assemblies that provide the same functionalities for different types of applications. You refer to the appropriate assemblies in an application based on the application type you are developing. For developing Windows Forms applications or WPF applications, you use Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.ClientRuntime.dll. For Silverlight applications you use Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll. For invoking the client object model through JavaScript you have to add the SP.js file. Table 8.1 shows where each client object model is located.

Table 8.1. SharePoint DLL Locations for Client Side API

Image

The client object model mimics the majority of the functionalities available as part of the server side API. While developing the client object model, Microsoft also had to keep in mind that it should resemble the server side API as closely as possible. This would help developers have an easier learning curve. Table 8.2 makes it clear how the client object model is similar to server APIs.

Table 8.2. Mapping of Client Side Classes to Server Side Classes

Image
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset