Tridion 2011 Core Service Console App

April 10th, 2012 | Posted by Robert Curlette in Tridion

Tridion implements the Core Service using WCF 3.5 and this is the suggested interface to use for accessing the Tridion API outside of the Event System or Templates. Although I have heard horror stories of the configuration options and how difficult WCF is to work with, so far I did not have such experiences using the Core Service with ‘Add Service Reference’ in Tridion and then doing simple things. Today was different.

Today I tried making a small Console application using the config-less Core Service code from Jaime Santos’s post about the Data Extenders. This brought me into touch with the various bindings and security aspects – and I had a new respect and fear of WCF that I had not known before. Jaime uses the tcp binding and I understand this is the best performing binding. However, my Tridion Server declined the connection for TCP and I assume the port is blocked. Then, I tried modifying his code to use an HTTP Binding – but many of the options he uses are TCP only and I was quickly making a mess of the code. For some strange reason I tried using a WSHTTP binging – but that wants me to use https and the Tridion WCF Core Service does not accept it (or maybe my web server is not configured for it?). By this time I took another look at the Config-less Core Service Example from Puf and found new inspiration for making this work. His example requires a password for the account while the TCP example did not. I wonder why this is? I borrowed Puf’s code and adapted it to take advantage of some of Jaime’s ideas in his Handler. During the process I learned that the TCP binding is much better performing and we need to explicitly open and close the connections – the cost of opening a connection is very high.

Jaime uses the Core Service in a Data Extender where performance is  extremely important, so I understand why Jaime choses the TCP binding over HTTP.

In the end I have a small Console app that calls the Core Service using a BasicHttp binding. It gives us an easy way to get started testing Core Service code that later might end up in a GUI Extension or Import app.

Get the Code at https://github.com/rcurlette/TridionCoreServiceConsole

 

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

One Response

  • Frank van Puffelen says:

    Hey Robert,

    Welcome to the modern world, where we get all excited to replace our custom (ASP) pages with little command line programs. 🙂 I have a whole collection of them now and they give me a whole new way to interact with any Tridion Content Manager I need to work with.

    The only way to connect to the Core Service without having a password is by using the SessionAwareCoreServiceClient’s Impersonate method, which is only available when you’re running the client on the same machine as the Tridion Content Manager. That makes sense: if your code is running as a configured impersonation user on the TCM the machine, it is already trusted and thus can call Impersonate. But code accessing Tridion remotely should definitely be required to authenticate, otherwise we’d have a huge security hole.



Leave a Reply

Your email address will not be published. Required fields are marked *