Saturday, February 22, 2014

Accessing A Sitecore Item From an External Application

In order to access a Sitecore Item outside of Sitecore you need to use the Sitecore Web Services or

Step 1: Register the Sitecore Web Service with your application. This is done by adding a reference.
You want a web reference not a service reference so be sure to click Advanced and click Web Reference.
The service can be found at

Step 3: Connect to the web service and get the item path for the id. If you already have the path then ignore this step.
com.scws.itempath.ItemPathService service = new com.scws.itempath.ItemPathService();
service.Url = serverUrl + "/sitecore/shell/webservice/ItemPathService.asmx";
string itemId = service.GetItemId(databaseName, itemPath);
return "<dataset><item_id>" + itemId + "</item_id></dataset>";

Step 4: Get the item based on the Sitecore Path. The service returns an xml but you then wrap it in dataset tags and you can stuff it in a dataset to query it. NOTE: Replace {sitecore_path} with the path you want to retrieve the item for.