Juan Carlos

What’s new in the SharePoint 2013 Client Side Object Model!

September 13th, 2012 | Author: | Filed under: Dev / Test, SharePoint | Tags: , , , , , , , ,


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.

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.

image

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:

image

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.

        static void TraduccionSincronaClientOM()
        {
            try
            {
                using (MO_Cliente.ClientContext ctx =
                    new MO_Cliente.ClientContext(
                        "http://c4431163311/"))
                {
                    string sEntrada = "http://c4431163311/Entrada/WordAutomation.docx";
                    string sSalida = "http://c4431163311/Salida/WordAutomationTraducido.docx";
                    MO_TRCliente.SyncTranslator stJob = 
                        new MO_TRCliente.SyncTranslator(
                            ctx, "en");
                    stJob.OutputSaveBehavior = 
                        MO_TRCliente.SaveBehavior.AlwaysOverwrite;
                    MO_Cliente.ClientResult<MO_TRCliente.TranslationItemInfo> cr = 
                        stJob.Translate(sEntrada, sSalida);
                    ctx.ExecuteQuery();
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(
                    "Error: ", 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!

About the author:
With more than 10 years of experience in the ICT sector, what best define me is the interest and knowledge of new technologies as a natural way for attending and solving customer problems and needs. My career in the TIC sector, and particularly in the .NET platform started in 2003, just after finishing my studies at the university, in the global worldwide consultancy company Accenture. There, I had the opportunity of working during 3 years in big national and international projects performing different task and roles: development of VB.NET applications, application test and deployment, management of small development teams and so on. In May 2006 I left Accenture and started a new adventure at the Microsoft Innovation Center in Cantabria (CIIN) as a Solutions Architect. In this new stage, I had the opportunity of knowing deeply a variety of Microsoft technologies such as SharePoint, Office 365, Windows Azure, Visual Studio, SQL Server Reporting Services, BizTalk, LINQ, Entity Framework, etc. At the CIIN I haved performed evangelism activities just around these technologies, and I have had the honor of belonging to one of the more specialized organizations in SharePoint in Spain. In October 2013 I joined LKS where I perform a Consultant and Solutions Architect role skilled in SharePoint and Office 365 platforms. My daily work in LKS is focused on providing SharePoint & Office 365 advice and consultancy, specialized training and evangelism in the different projects and LKS customers where I’m involved.

Comments are closed.