Tuesday, January 5, 2016

Tridion Custom Tools Example Projects – Core Service (.NET)

In the series of blog posts for Tridion Custom Tools Example Projects, in this blog I am explaining to set up a simple core service project and sharing the Example Code. Also you can install a visual studio project template for the same, the VSIX file can be found here

The Core Service is a Web service that allows applications to interact with the Content Manager. For example, Content Manager clients such as Experience Manager and Content Manager Explorer interact with the Content Manager through the Core Service, and you can use the Core Service to integrate external systems with SDL Tridion.

Setting up the project (Using the built-in .NET client)

1. Open Visual Studio and create a project (Console or Web according to your need) .

2. Copy the  Tridion.ContentManager.CoreService.Client assembly from bin\client subdirectory of %TRIDION_HOME% (defaults to C:\Program Files (x86)\Tridion\) to a location.

3. Add a reference to the Tridion.ContentManager.CoreService.Client assembly in the project from the copy location.

4. Add references to System.ServiceModel and System.Runtime.Serialization assemblies.

5. In the same folder, find the file Tridion.ContentManager.CoreService.Client.config and copy the WCF endpoint configuration you find in that file into your application's configuration file.

6. Use Tridion.ContentManager.CoreService.Client namespace to create CoreServiceClient object.

Alternatively, one can also create a proxy client creating a service reference in to the project.

Creating the core service client object:

To interact with CM, we need a core service client object and to create it, Endpoints (defined in applications config file) are used. In WCF terms, an Endpoint is simple collection of Address, Binding and Contract.

There are three default bindings:  BasicHttpBinding (SOAP), WSHttpBinding (WCF) and NetTcpBinding (network). These are used to connect to the Core Service from your SOAP, WCF or network client. You can find more about the default bindings here.

Different types of core service clients are listed here, which are used for different purposes. In this code example I am using SessionAwareCoreServiceClient to interect with Tridion Content Manager. 

Once the core service client object is created, it can be used to interact with Tridion CM. Have a look at the example code here.

No comments:

Post a Comment