Using the Framework API in the context of a Web Service

  • Updated

The following code sample shows how to create a custom Web service that exposes the Framework API for use in a Web service. You should use this method when you implement Web Services within Ektron because of the increased performance and discoverability of the Framework API.

<%@ WebService Language="C#" class="ContentManagerWebService" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Ektron.Cms;
using Ektron.Cms.Framework;
using Ektron.Cms.Framework.Content;

/// <summary>
/// This Web service exposes the framework API by modifying the calls traditionally done on a webform.
/// </summary>
/// Below add desired namespace
[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.  
// [System.Web.Script.Services.ScriptService]
public class ContentManagerWebService : System.Web.Services.WebService  
    //must have web method to called
    public void TesContentAddService1 ()
        ContentManager contentManager = new ContentManager(ApiAccessMode.Admin);
        ContentData contentData = new ContentData()
            FolderId = 190,
            Title = "NewContent2",
            Teaser = "Summary1",
            Html = "Information",
            IsPrivate = false,
            IsPermissionsInherited = true
        contentData.MetaData = new ContentMetaData[1];
        contentData.MetaData[0] = new ContentMetaData()
            Id = 130,
            Text = "Important MetaData"