Accessing Ektron from a standalone application
Ever tried pulling ektron contents from a standalone application?
I have been working with Ektron CMS for the past one year, and recently I got a requirement from one of our customer to fetch contents from Ektron to a non-ektron instance and vice versa. I was left with various thoughts and solutions to do this stuff. Finally I got it done and the data is flowing from the non ektron instance to ektron instance seamlessly.
Here, I am going to share you that story of what I did to satisfy the requirement.
The two main approaches that could solve this requirement involve:
- Using ektron API’s
- Using ektron web services
Using Ektron API’s
Ektron API’s can be used in a non-ektron instance by making use of the three tier DLL’s provided by ektron. These DLL’s along with few config files will allow us to use Ektron API’s from a standalone application. The three tier DLL’s internally calls the ektron services to provide the functionalities.
This approach uses many DLL’s and large number of other files in order to get things up and running, and I didn’t find this as a neat solution, the next choice was making use of Ektron’s web services.
Using ektron web services
Ektron provides web services that expose functions to interact with the system for making use of its functionalities. The advantage of using this approach is that it doesn’t need reference to any ektron DLL’s also we don’t need to use any config files provided by ektron.
This is definitely a cleaner solution for me!
The ASMX web services implemented in Ektron can be found at: root/Workarea/webservices
Few examples involve the following:
- Content.asmx – provides content related functionalities
- Blog.asmx – provides blog related functionalities
- Taxonomy.asmx – provides taxonomy related functionalities
- User.asmx – provides user related functionalities
Now coming back to my requirement, I am supposed to pull data from ektron and import data to ektron from a standalone application, assume that I am using a console application to do the data migration.
The steps that I followed include:
Using wsdl.exe to generate web service proxy class:
Wsdl tool generates code for the XML based web services. With this we can create a c# proxy class for the Content service.
The command is as follows,
wsdl /out:contentProxyClass.cs your-host-name/Workarea/webservices/WebServiceAPI/Content/Content.asmx
Compile proxy class to a proxy DLL:
Now we can compile the proxy class to a DLL with the following command,
csc /target:library /out: ContentServiceProxy.DLL contentProxyClass.cs
Call proxy DLL from console application:
Almost there! Now we can call the proxy DLL from the console application. The functions are similar to those in Ektron’s framework API.
The sample code snippet to pull content from ektron is as follows:
Content content=new Content(); content.AuthenticationHeaderValue=new AuthenticationHeader(); content.AuthenticationHeaderValue.Username="CMS User Name"; content.AuthenticationHeaderValue.Password="CMS User Password"; ContentData contentData=new ContentData(); contentData=content.GetContent(30,ContentResultType.Published);
As ektron doesn’t allow unauthenticated remote calls, a valid CMS user credentials needs to be passed in order to execute the web service calls.
Similarly the content service provides function to add a new content to the CMS.
Thus by using the Content service I was able to pull data from ektron and push data to ektron from a standalone application.
Thus by using the web services of ektron we can leverage the capabilities of Ektron from a non ektron application.
Got questions? Leave a comment here or get in touch with our Ektron team.