Java Example of Retrieving a Service Endpoint on a
vCenter Server
Instance
Last Updated December 16, 2024

This example provides a common pattern for filtering Lookup Service registration data. This example is based on the code in the
LookupServiceHelper.java
sample file.
This example uses the steps that are described in the Retrieve Service Endpoints on vCenter Server Instances procedure.
For a complete and up-to-date version of the Java sample code, see the
vsphere-automation-sdk-java
VMware repository at GitHub.
...

/**
 * Define filter criterion for retrieving a service endpoint. 
 * Omit the nodeID parameter to retrieve the endpoints hosted 
 * on all vCenter Server instances in the environment.
 */

  List<LookupServiceRegistrationInfo> lookupServiceUrls(String prod, 
                                                        String svcType, 
                                                        String proto, 
                                                        String epType, 
                                                        String nodeID){
 
    LookupServiceRegistrationServiceType filterServiceType = 
                                                     new LookupServiceRegistrationServiceType();
    filterServiceType.setProduct(prod);
    filterServiceType.setType(svcType);
   
    LookupServiceRegistrationEndpointType filterEndpointType = 
                                                     new LookupServiceRegistrationEndpointType();
    filterEndpointType.setProtocol(proto);
    filterEndpointType.setType(epType);
   
    LookupServiceRegistrationFilter filterCriteria = new LookupServiceRegistrationFilter();
    filterCriteria.setServiceType(filterServiceType);
    filterCriteria.setEndpointType(filterEndpointType);
    filterCriteria.setNode(nodeID);
   
    return lsPort.list(serviceRegistration, filterCriteria);
  }  

...