This example provides a common pattern for filtering Lookup Service registration data. This example is based on the code in the LsConnection.cs sample file. The file is located in the following vCloud Suite SDK for .NET directory: client/samples/src/Samples/vmware/vcloud/suite/samples/common/

This example uses the steps that are described in the Retrieve Service Endpoints on vCenter Server Instances procedure.

using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using vmware.lookupservice;
 
public LookupServiceRegistrationInfo[] LookupSingleServiceUrl(string prod,
                                                              string sType,
                                                              string proto,
                                                              string eType,
                                                              string nodeId)
{
  // 1 - Create a filter criterion for service info.
  var filterServiceType = new LookupServiceRegistrationServiceType();
  filterServiceType.product = prod;
  filterServiceType.type = sType;
 
  // 2 - Create a filter criterion for endpoint info.
  var filterEndpointType = new LookupServiceRegistrationEndpointType();
  filterEndpointType.protocol = proto;
  filterEndpointType.type = eType;
 
  // 3 - Create the registration filter object.
  var filterCriteria = new LookupServiceRegistrationFilter();
  filterCriteria.serviceType = filterServiceType;
  filterCriteria.endpointType = filterEndpointType;
  filterCriteria.nodeId = nodeId;
 
  // 4 - Retrieve specified service info with the List() method.
  return lsPort.List(serviceRegistration, filterCriteria);
}