Thursday, December 23, 2010

Akamai - Sitecore and CCU Web Services

I just wrapped up work to integrate the Akamai Content Control Utility webservices and automatic purging from Sitecore.

Using the Telerik RadFileExplorer and some crafty C# code I am now able to trigger content purging from the Sitecore Desktop. Just created the service object, collected the parameters and called the webservice.

Pretty cool, I even get an email once the purge has been completed.

//create the purgeResult object
X.Web.Isc.UI.ServiceReference1.PurgeResult r = new X.Web.Isc.UI.ServiceReference1.PurgeResult();
X.Web.Isc.UI.ServiceReference1.PurgeApiClient a;

a = new X.Web.Isc.UI.ServiceReference1.PurgeApiClient();
string[] options = new string[4];
string[] uri = new string[1];

//get the login credential and other data for Akamai from the web.config
options[0] = ConfigurationManager.AppSettings["AkamaiCCUEmail"].ToString();
options[1] = ConfigurationManager.AppSettings["AkamaiCCUAction"].ToString();
options[2] = ConfigurationManager.AppSettings["AkamaiCCUType"].ToString();
options[3] = ConfigurationManager.AppSettings["AkamaiCCUDomain"].ToString();

//build the URL to the file that was uploaded

uri[0] = "http://www.mydomain.com" + e.Path;

//request the content purge
r = a.purgeRequest(ConfigurationManager.AppSettings["AkamaiCCUUserName"].ToString(), ConfigurationManager.AppSettings["AkamaiCCUPassword"].ToString(), "", options, uri);

//log the activity
X.Web.Core.Context.Current.LogMessage("Akamai CCU WebService Message: " + r.resultCode + " " + r.resultMsg + " " + r.sessionID + " " + uri[0].ToString());

}
catch (Exception ex)
{
//something didn't work so let's report the issue
X.Web.Core.Context.Current.LogMessage("Error Akamai CCU WebService Message: ", ex);
}

No comments:

Post a Comment