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_DIME has been set to the following URI: http://localhost:<port>/wsi/FNCEWS35DIME/wsdl.
using System; using Microsoft.Web.Services2; using Microsoft.Web.Services2.Security.Tokens; using getsearchmetadata_ex.CEWS_DIME; namespace getsearchmetadata_ex { /// <summary> /// Example GetSearchMetadata call that lists the DisplayName /// property value of the properties in the Folder and Document classes. /// </summary> class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { const string url = "http://localhost:9080/wsi/FNCEWS35DIME/"; // Change port number if necessary const string objectStore = "ContentEngineExs"; // Pre-existing object store // Create a wse-enabled web service object to provide access to SOAP header FNCEWS35ServiceWse wseService = new FNCEWS35ServiceWse(); wseService.Url = url; SoapContext soapContext = wseService.RequestSoapContext; // Add security token to SOAP header with your username and password UsernameToken token = new UsernameToken("username", "password", PasswordOption.SendPlainText); soapContext.Security.Tokens.Add(token); // Add default locale info to SOAP header Localization defaultLocale = new Localization(); defaultLocale.Locale = "en-US"; // Create GetSearchMetadataRequest GetSearchMetadataRequest elemGetSearchMetadataRequest = new GetSearchMetadataRequest(); ObjectStoreScope elemObjectStoreScope = new ObjectStoreScope(); elemObjectStoreScope.objectStore = objectStore; elemGetSearchMetadataRequest.SearchScope = elemObjectStoreScope; elemGetSearchMetadataRequest.ClassFilter = "Folder Document"; //Construct Property Filter PropertyFilterType elemPropertyFilterType = new PropertyFilterType(); elemPropertyFilterType.maxRecursion = 1; elemPropertyFilterType.maxRecursionSpecified = true; elemPropertyFilterType.IncludeProperties = new FilterElementType[1]; elemPropertyFilterType.IncludeProperties[0] = new FilterElementType(); elemPropertyFilterType.IncludeProperties[0].Value = "PropertyDescriptions DisplayName"; elemGetSearchMetadataRequest.PropertyFilter = elemPropertyFilterType; // Invoke GetSearchMetadata GetSearchMetadataResponse elemGetSearchMetadataResponse = wseService.GetSearchMetadata(elemGetSearchMetadataRequest); // Display DisplayName property values, by class if (elemGetSearchMetadataResponse.Object == null) { Console.WriteLine("No ClassDescription objects were returned."); } else { // Get each returned ClassDescription object foreach (ObjectValue objClassDescription in elemGetSearchMetadataResponse.Object) { if (objClassDescription.Property == null) { Console.WriteLine("No properties returned for ClassDescription {0}.", objClassDescription.objectId); } else { // Get each PropertyDescription for the ClassDescription ListOfObject propPropertyDescriptions = null; foreach (PropertyType propProperty in objClassDescription.Property) { if (propProperty.propertyId == "DisplayName") { Console.WriteLine("Class {0}:", ((SingletonString)propProperty).Value); } else if (propProperty.propertyId == "PropertyDescriptions") { propPropertyDescriptions = (ListOfObject)propProperty; } } if ((propPropertyDescriptions == null) || (propPropertyDescriptions.Value == null)) { Console.WriteLine(" No PropertyDescriptions were returned."); } else { // Get DisplayName for each returned property foreach (DependentObjectType objDependentObjectType in propPropertyDescriptions.Value) { SingletonString propDisplayName = (SingletonString)objDependentObjectType.Property[0]; Console.WriteLine(" {0}", propDisplayName.Value); } } Console.WriteLine("Press Enter to continue"); Console.ReadLine(); } } } } //Main } // class1 }