What’s new in the SharePoint 2013 Client Side Object Model!
To get articles like this free in your inbox, subscribe to our newsletter.
So the question here is: What’s new in SharePoint 2013 CSOM? Well, of course the API is there (in the 15 hive) and Microsoft has increased the possibilities of building applications with the CSOM adding new assemblies that allow developers not only to interact with SharePoint sites but also use some of the key SharePoint 2013 services like Search, Managed Metadata or the new Translation service.
Want to save money on SharePoint and have less overhead for general support and maintenance? Talk to our experts!
As happened in previous versions of SharePoint, SharePoint 2013 is not only a product but also a development platform. Which means you can build new functionalities and capabilities on top of the ones available out of the box. SharePoint 2010 introduced a new extensibility point to build client applications on top of the server object model using a new API: the client side object model (CSOM). The idea behind the CSOM was just to enable developers to work remotely with SharePoint sites without having to use default web services or creating new ones. Microsoft introduced three different programming flavors for creating client applications using the CSOM: .NET, Silverlight and ECMAScript. Even each flavor has its own rules and patterns when using it, behind the scenes all of them do the same: send commands to the server through a WCF (Windows Communication Foundation) service and wait for the server answer.
CSOM Architecture
The foundations of the CSOM architecture in SharePoint 2013 are quite similar to the ones in SharePoint 2010, replacing the “client.svc” WCF service for a new REST API named _api. This REST API is the foundation to use REST to interoperate with SharePoint sites but also to use the CSOM.
As you can see, in SharePoint 2013 we have the same three programming flavors for the CSOM, .NET – Silverlight – ECMAScript, which sends commands to the new REST _api and wait for the related answer.
New CSOM assemblies
New assemblies have been provided to developers in order to use some of the SharePoint 2013 services. You can find there in the following locations:
- .NET flavor (synchronous nature), located at the path [..]\15\ISAPI. It allows you to create desktop or web applications that can interoperate remotely with SharePoint 2013 services and sites.
- Silverlight flavor (asynchronous nature), located at the path [..]\15\TEMPLATE\LAYOUTS\ClientBin. It allows you to build Silverlight applications deployed and used inside SharePoint sites. Silverlight provided rich user interfaces when building custom solutions on top of SharePoint.
- ECMAScript (asynchronous nature), located at the path [..]\TEMPLATE\LAYOUTS.
Bellow you can see a screenshot showing some of the assemblies available for the .NET CSOM:
CSOM in action: using the new Translation Service Application from a client application
For instance, you can easily use the new Translation Service Application to translate documents in a CSOM application. You have access to either synchronous or asynchronous translation capabilities. You only need to create a ClientContext instance and you are ready to work remotely with the service by using new classes provided by Microsoft. In this case, just create a SyncTranslator instance, configure the translation job and make a call to the Translate() method. Once you call the ExecuteQuery() method you are done and you’ll have your document translated.
<span class="kwrd">static</span> <span class="kwrd">void</span> TraduccionSincronaClientOM() { <span class="kwrd">try</span> { <span class="kwrd">using</span> (MO_Cliente.ClientContext ctx = <span class="kwrd">new</span> MO_Cliente.ClientContext( <span class="str">"http://c4431163311/"</span>)) { <span class="kwrd">string</span> sEntrada = <span class="str">"http://c4431163311/Entrada/WordAutomation.docx"</span>; <span class="kwrd">string</span> sSalida = <span class="str">"http://c4431163311/Salida/WordAutomationTraducido.docx"</span>; MO_TRCliente.SyncTranslator stJob = <span class="kwrd">new</span> MO_TRCliente.SyncTranslator( ctx, <span class="str">"en"</span>); stJob.OutputSaveBehavior = MO_TRCliente.SaveBehavior.AlwaysOverwrite; MO_Cliente.ClientResult<MO_TRCliente.TranslationItemInfo> cr = stJob.Translate(sEntrada, sSalida); ctx.ExecuteQuery(); } } <span class="kwrd">catch</span> (Exception ex) { Console.WriteLine( <span class="str">"Error: "</span>, ex.Message); } }
And that’s all about new stuff in CSOM. I recommend you to check it in your SharePoint 2013 CloudShare environment. Happy CloudSharing!
Want to save money on SharePoint and have less overhead for general support and maintenance? Talk to our experts!
What you should do next…
1. Subscribe to our newsletter:
Subscribe to our newsletter below for the latest news, advice and thought-leadership for software professionals. Or visit our blog to browse our most recent articles.
2. Learn how virtual labs can grow your business:
To learn more about how CloudShare helps software organizations grow revenue, increase efficiency and improve quality, visit our resources page. You’ll be able to browser dozens of valuable white papers, eBooks, webinars, case studies, and brochures.
3. Get a FREE, no obligation demo:
Discover just how easy it is to create your cloud environment—in minutes! One of our friendly virtual labs experts will be happy to:
- Show you the platform in action
- Calculate pricing for your business
- Set you up with a 14-day free trial
- Answer any questions you have
- No pressure or obligation