Tuesday, July 12, 2011

Client Object Model – SharePoint 2010 / SharePoint Foundation 2010

New client object model is introduced in SharePoint 2010 and Foundation 2010. Let us see what this new client model is all about and why has this been introduced.

Note: please consider term Client Object Model wherever I use COM word. It has nothing to do with COM windows component.

Earlier to 2010 environment, in 2007 if we want to access SharePoint data outside of server environment, we had only one choice and that was obvious a web service.

We had two options. A code that runs on the server which requires server API and a code that runs on a client which requires calling web services. Calling web services and fetching result and then manipulating that result was not that easy. There were so many different ways to iterate through results, different ways to query SharePoint from web services. These were never an easy job.

Intention of client object model helps developer to write a code which runs on the client and call server without using web services. So the main advantage is you no need to install SharePoint for development.


There are three different client object model in SharePoint 2010.
1) .Net managed client model - This is used via .Net CLR – you need to add Microsoft.SharePoint.Client.dll, Microsoft.SharePoint.Client.Runtime.dll for this. You can find them in 14 hives ISAPI folder.

2) Silverlight client – we can use SharePoint DLLs to be used in Silverlight applications which can be integrated to the SharePoint 2010. SharePoint 2010 provides a great ways to integrate Silverlight applications to the environment. You can deploy your applications as well as you can just upload your entire Silverlight application in document library and use it in SharePoint 2010. You need to add Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll for this. You can find them in 14\TEMPLATE\LAYOUTS\ClientBin folder.

3) ECMA script client model – Now we have a flexibility to call SharePoint data from JavaScript as well. We can get a context of SharePoint objects now in JavaScript. You need to add SP.js file for this. You can find this in 14\TEMPLATE\LAYOUTS folder.

Other big advantage is that you no need to learn a complete new classes and objects. It’s just that there are some different names of classes now. Those names are not changed much. Example, SPContext has become ClientContext, SPSite has become Site, SPWeb has become Web, SPList has become List.

Small changes have been done and few different ways of creating list, list items, iterating through items, fetching data through query have been introduced in client object model. We are going to see as many examples as we can as we move along with the series.

The way COM works is it bundles all request made to the server in to a XML form and then passes to the server, processes them on the server and then return the JSON response. We have to read the JSON response and then process the result. We do not have to process actually, it’s just that it returns the response and we can use different techniques to read them. We are going to see them all as we proceed with this beautiful journey with COM.

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com