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
http://{sitecore server url}/sitecore/shell/WebService/service.asmx?wsdl
Step 2: If you require getting item by Sitecore Path then you need to my Sitecore Get Item Id For Item Path Web Service Module in Marketplace. You would place the dll in the right folder and the asmx in the services folder to access it.
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.
com.scws.Credentials cred = new com.scws.Credentials();
cred.UserName = userName;
cred.Password = password;
com.scws.VisualSitecoreService service = new com.scws.VisualSitecoreService();
service.Url = serverUrl + "/sitecore/shell/WebService/service.asmx";
// Verify Credentials
var xn = service.GetXML({sitecore path}, false, databaseName, cred);
return "<dataset>" + xn.InnerXml + "</dataset>";
This should work to get your item. If you have any questions please email Dennis.Augustine@threepointturn.com or Chris.Wiliams@threepointturn.com and we will assist.
No comments:
Post a Comment