8

I am writing an application which will trigger workflow on any items that use ECL components when they are modified in the external content library. My original idea was to create a simple web service which receives messages from the external system with a signature something like the following:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; 
using System.Web.Services;
using System.Xml.Linq;
using Tridion.ContentManager;
using Tridion.ExternalContentLibrary.V2;
using Tridion.ContentManager.CoreService.Client;
namespace UrbanCherry.Net.Tridion.ECL
{
    /// <summary>
    /// Summary description for ECLUpdateService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    // [System.Web.Script.Services.ScriptService]
    public class ECLUpdateService : System.Web.Services.WebService
    {
        /// <summary>
        /// UpdateECLItem will recieve a message that an ECL item has changed
        /// </summary>
        /// <param name="mountPoint">ID of the mountpoint I want to use</param>
        /// <param name="itemID">External ID of the item</param>
        /// <param name="actionType">Update type (Delete or Update)</param>
        /// <returns></returns>
        [WebMethod]
        public string UpdateECLItem(String mountPoint, String itemID, ActionType actionType)
        {
            //Do my magic
            return "OK";
        }

    }
}

My external id can easily be converted into the ECLURI as follows:

String eclItemID = "ecl:" + pubID + "-" + mountPoint + "-" + itemID + "-img-file";

The first thing my service needs to do is map the ECLURI to the TCMURI of the stub item. There seems to be no method for doing this using the Core Service, but I can achieve this by using the SessionFactory object as follows:

    Session  tcmSession = new Session();
    IEclSession eclSession = SessionFactory.CreateEclSession(tcmSession);
    String tcmURI = eclSession.TryGetTcmUriFromEclUri(eclSession.HostServices.CreateEclUri(eclItemID));

However, I understand that creating a new session object in external code is not supported/recommended. If this is really the case, the only solution I have is to create some kind of mapping database table to store the relationships. This seems like overkill when eclSession.TryGetTcmUriFromEclUri() does exactly what I need. Can anyone think of how I can either execute eclSession.TryGetTcmUriFromEclUri from a supported context (which can be triggered from an external application), or mimic it in some other way without needing to create a custom lookup table?

4

You have SessionFactory.CreateEclSession(string username). You will need to make sure the usual core service bindings are available in the config for your process.

I would expect this method to be deprecated when (if) the EclService becomes a public interface, but then it will be according to standard deprecation policies giving you some time to get migrated. It will come with the penalty of spinning up a new TOM.NET process, so you can of course also try to use the EclService directly... but be prepared to make changes when upgrading to a new version of Tridion if you go down this path.

|improve this answer|||||
  • Thanks Lars, so will SessionFactory.CreateEclSession(string username) use the core service or the same TOM.NET approach of creating a new Session? Do I need to copy the whole Tridion.ConentManager.config into my web.config, or just use the CoreService bindings? – Chris Summers Jun 7 '13 at 14:44
  • It will use TOM.NET. I would think you can get away with referencing the main config file though. I would look in the config files of the Tridion processes to see if there was something I could be "inspired" by. :) – Lars Møllebjerg Jun 7 '13 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.