The interfaces ISessionAwareCoreService and ICoreService are almost identical, ISessionAwareCoreService has couple of more methods than ICoreService.

It seems to me like ISessionAwareCoreService could easily inherit from ICoreService, but it does not. I guess there is a good reason behind it.

(Does anyone know why?)

Anyways, let's get to the topic. I'm creating an extension method for ComponentData as shown below:

public static SchemaData GetSchemaData(this ComponentData data, ICoreService client)
    return client.Read(data.Schema.IdRef, new ReadOptions(){}) as SchemaData;

The consumer of this class should inject the "client" object obviously, and it has to be type of ICoreService.

But what if the consumer is using SessionAwareCoreServiceClient?


Are you sure? If you look at the API, you will see that it does actually (note that these are the versioned interfaces)

enter image description here

The main difference between the two is that the session aware let's you work with sessions and has the ability to impersonate someone else. Also one important difference is that when using the SessionAwareCoreServiceClient you cannot use BasicHttp binding.

To answer your main question, the most primitive solution would be to overload the extension method :)

  • Hi @Atila Sos, Thanks for the swift answer. Where is that "Tridion.ContentManager.CoreService.dll" supposed to be? I have only "Tridion.ContentManager.CoreService.Client.dll" p.s:I actually typed a sentence like "please don't recommend overloading" but then removed it in the end. lol! Jul 26 '18 at 16:57
  • Hm, now that you mention it, the Tridion.ContentManager.CoreService.Client.dll is indeed the right one, it contains the pre-built proxy classes, but I don't know recall their inheritance from the top of my head. However, if I think back hard enough, I do vaguely remember having a similar struggle as you have. I will have to check this and will update my answer accordingly afterwards .
    – Atila Sos
    Jul 26 '18 at 17:52
  • The confusion here is that the Core Service API docs are generated from the server-side types. The client-side types are generated from the WSDL and the interface inheritance gets lost in that process. Jul 26 '18 at 17:53
  • Great point Rick - one to remember where looking at types, methods etc.
    – Neil
    Jul 27 '18 at 13:22

I'm considering to create my own interface Custom.ICoreService that's inheriting from Tridion.ContentManager.CoreService.Client.ICoreService and service clients inheriting from that custom interface as well as actual Tridion Core Service clients. It will allow me to pass 'Custom.ICoreService' objects around while preserving the exact same functionality as the actual clients.

public interface ICoreService : Tridion.ContentManager.CoreService.Client.ICoreService
public class CoreServiceClient : Tridion.ContentManager.CoreService.Client.CoreServiceClient, ICoreService
public class SessionAwareCoreServiceClient : Tridion.ContentManager.CoreService.Client.SessionAwareCoreServiceClient, ICoreService

However, it doesn't feel right.

Any thoughts?

  • It would work, I guess. As a matter of fact, you don’t need to define your own (marker) interface. Just a subclass of SessionAwareCoreServiceClient which implements the standard ICoreService would do the job (?) Jul 30 '18 at 20:58

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.