The following code example illustrates how to use the GetSearchMetadata operation to retrieve the metadata from the results of a repository search. This example assumes a web reference named CEWS has been set to the following URI: http://localhost:<port>/wsi/FNCEWS40MTOM/wsdl.
using System; using Microsoft.Web.Services3; using Microsoft.Web.Services3.Security.Tokens; using Microsoft.Web.Services3.Design; using getsearchmetadata_ex.CEWS; namespace getsearchmetadata_ex { /// <summary> /// GetSearchMetadata call that lists the DisplayName property value of the properties in the Folder and Document classes. /// </summary> class Class1 { static void Main(string[] args) { const string strUrl = "http://localhost:9080/wsi/FNCEWS40MTOM/"; // Change port number if necessary const string strObjStoreName = "ContentEngineExs"; // Pre-existing object store // Create a wse-enabled web service object FNCEWS40ServiceWse wseService = new FNCEWS40ServiceWse(); // Set security token with your username and password UsernameToken token = new UsernameToken("username", "password", PasswordOption.SendPlainText); wseService.SetClientCredential(token); Policy MyPolicy = new Policy(); MyPolicy.Assertions.Add(new UsernameOverTransportAssertion()); wseService.SetPolicy(MyPolicy); wseService.Url = strUrl; wseService.RequireMtom = true; // Add default locale info to SOAP header Localization objDefaultLocale = new Localization(); objDefaultLocale.Locale = "en-US"; // Create GetSearchMetadataRequest GetSearchMetadataRequest objGetSearchMetadataRequest = new GetSearchMetadataRequest(); ObjectStoreScope objObjectStoreScope = new ObjectStoreScope(); objObjectStoreScope.objectStore = strObjStoreName; objGetSearchMetadataRequest.SearchScope = objObjectStoreScope; objGetSearchMetadataRequest.ClassFilter = "Folder Document"; //Construct Property Filter PropertyFilterType objPropertyFilterType = new PropertyFilterType(); objPropertyFilterType.maxRecursion = 1; objPropertyFilterType.maxRecursionSpecified = true; objPropertyFilterType.IncludeProperties = new FilterElementType[1]; objPropertyFilterType.IncludeProperties[0] = new FilterElementType(); objPropertyFilterType.IncludeProperties[0].Value = "PropertyDescriptions DisplayName"; objGetSearchMetadataRequest.PropertyFilter = objPropertyFilterType; // Invoke GetSearchMetadata GetSearchMetadataResponse objGetSearchMetadataResponse = wseService.GetSearchMetadata(objGetSearchMetadataRequest); // Display DisplayName property values, by class if (objGetSearchMetadataResponse.Object == null) { Console.WriteLine("No ClassDescription objects were returned."); } else { // Get each returned ClassDescription object foreach (ObjectValue objClassDescription in objGetSearchMetadataResponse.Object) { if (objClassDescription.Property == null) { Console.WriteLine("No properties returned for ClassDescription {0}.", objClassDescription.objectId); } else { // Get each PropertyDescription for the ClassDescription ListOfObject prpPropertyDescriptions = null; foreach (PropertyType prpProperty in objClassDescription.Property) { if (prpProperty.propertyId == "DisplayName") { Console.WriteLine("Class {0}:", ((SingletonString)prpProperty).Value); } else if (prpProperty.propertyId == "PropertyDescriptions") { prpPropertyDescriptions = (ListOfObject)prpProperty; } } if ((prpPropertyDescriptions == null) || (prpPropertyDescriptions.Value == null)) { Console.WriteLine(" No PropertyDescriptions were returned."); } else { // Get DisplayName for each returned property foreach (DependentObjectType objDependentObjectType in prpPropertyDescriptions.Value) { SingletonString prpDisplayName = (SingletonString)objDependentObjectType.Property[0]; Console.WriteLine(" {0}", prpDisplayName.Value); } } Console.WriteLine("Press Enter to continue"); Console.ReadLine(); } } } } } }