SharePoint 2010: Choosing the Correct API
Introduction
SharePoint has several different API's (Application Programming Interface). This article outlines reasons to help you decide which API is correct choice (or best fit) for your solution or project.
Available API's
- SharePoint object model
- SharePoint web services
- SharePoint Client object model
- Custom WCF service around server-side object model
Server-Side Object Model
Advantages
- Server-side API is more comprehensive
Disadvantages
- the server-side object model provides the most extensive set of options for developing customization's, but it can only be used on computers that are running a version of SharePoint 2010
Web Services
The Web services provide a fuller range of capabilities than the managed client object model, but they do not provide the same performance and design advantages, such as batching and exception handling. When you develop client-side applications, you should use the managed client object model whenever possible.
Client Object Model (CSOM)
This API combines most of all the features of the web services, so you will not have to make multiple soap requests to accomplish the same thing. The CSOM also batches up API calls into one request when you call ExecuteQuery. You will not be able to replicate this good performance with your own custom WCF service. There are few things that the CSOM does not do. One is cross site collection searching, term set management, and user profile management.
Custom WCF Service as Wrapper for Server-Side Object Model
my preference lies in building a custom WCF wrapper. Not only do I find the client object model sometimes somewhat odd to program against (but hey, that's personal), you regularly meet some limits where you don't expect them, not only in the areas mentioned by Steve (one example is web part interaction). For me, it can have several important advantages to create a custom WCF, mainly:
- The possibility to leverage AppFabric (features such as monitoring, instance management, and enterprise level cache).
- If you play your cards right, you can use .NET 4 and parallel programming techniques:http://sharepointdragons.com/2011/10/07/parallel-programming-in-sharepoint-2010-the-back-to-the-future-pattern/ If you talk about good performance for your custom WCF service, this def. won't be matched by the client object model.
Other Languages
This article is also available in the following languages