Data Access for Client Applications
In the previous version of SharePoint products and technologies, your options for accessing data from client applications were largely limited to the SharePoint ASP.NET Web services. The lack of a strongly-typed object model and the need to construct complex Collaborative Application Markup Language (CAML) queries in order to perform simple data operations made the development of SharePoint client applications challenging and somewhat limited. SharePoint 2010 introduces several new data access mechanisms that make it easier to build rich Internet applications (RIAs) that consume and manipulate data stored in SharePoint. There are now three principal approaches to accessing SharePoint data from client applications:
- The client-side object model. The client-side object model (CSOM) consists of three separate APIs that provide a subset of the server-side object model for use in client applications. The ECMAScript object model is designed for use by JavaScript or JScript that runs in a Web page, the Silverlight client object model provides similar support for Silverlight applications, and the .NET managed client object model is designed for use in .NET client applications such as WPF solutions.
- The SharePoint Foundation REST interface. The SharePoint Foundation Representational State Transfer (REST) interface uses WCF Data Services (formerly ADO.NET Data Services) to expose SharePoint lists and list items as addressable resources that can be accessed through HTTP requests. In keeping with the standard for RESTful Web services, the REST interface maps read, create, update, and delete operations to GET, POST, PUT, and DELETE HTTP verbs respectively. The REST interface can be used by any application that can send and retrieve HTTP requests and responses.
- The ASP.NET Web Services. SharePoint 2010 continues to expose the ASMX Web services that were available in SharePoint 2007. Although these are likely to be less widely used with the advent of the CSOM and the REST interface, there are still some scenarios in which these Web services provide the only mechanism for client-side data access. For future compatibility, use CSOM and REST where possible.
Note
In addition to these options, you can develop custom Windows Communication Foundation (WCF) services to expose SharePoint functionality that is unavailable through the existing access mechanisms. For more information about this approach, see WCF Services in SharePoint Foundation 2010 on MSDN.
The product documentation for SharePoint 2010 includes extensive details about each of these approaches, together with examples and walkthroughs describing approaches to common client-side data access requirements. This documentation focuses on the merits and performance implications of each approach for different real-world scenarios, and it presents some guidance about how to maximize the efficiency of your data access operations in each case. Before you start, you need a broad awareness of the capabilities of each approach. The following table shows what you can do in terms of data access with the CSOM, the REST interface, and the ASP.NET Web services.
CSOM |
REST interface |
Web services |
|
---|---|---|---|
List queries |
|||
List join queries |
* |
||
External list queries |
|||
View projections |
|||
Request batching |
|||
Synchronous operations |
(except ECMA) |
||
Asynchronous operations |
|||
SharePoint Foundation object model access |
|||
Access to SharePoint Server functionality (beyond SharePoint Foundation) |
|||
Support non-Windows clients |
(ECMA only) |
||
Support strongly-typed LINQ queries |
(objects only, no list queries) |
(with proxy, lists only) |
*The REST interface will perform implicit list joins, but only to satisfy where clause evaluation.
This section includes the following topics:
- Using the Client Object Model. This topic describes the capabilities, performance, and limitations of accessing data using the CSOM.
- Using the REST Interface. This topic describes the capabilities, performance, and limitations of accessing data using the SharePoint REST interface.
Because the ASP.NET Web services exposed by SharePoint 2010 work in the same way as the previous release, they are not covered in detail here. Generally speaking, you should prefer the use of the CSOM or the REST interface over the ASP.NET Web services when they meet your needs. However, the Web services expose some advanced data, such as organization profiles, published links, search data, social data, and user profiles, which is unavailable through the CSOM or the REST interface. For more information about the ASP.NET Web services exposed by SharePoint 2010, see SharePoint 2010 Web Services on MSDN.
Note
There are also scenarios in which you may want to use the client-side APIs to access data from server-side code. Although the CSOM, the REST interface, and the SharePoint ASP.NET Web services are all available when you develop server-side code, the use of these APIs in server-side code is only recommended for accessing data from another farm. Using the server-side object model is more efficient than using any of the client-side APIs.