The example is based on the code in the LookupServiceHelper.java sample file. The file is located in the following vCloud Suite SDK for Java directory: client/samples/java/vmware/vcloud/suite/samples/common/
This example uses the steps that are described in the Connect to the Lookup Service and Retrieve the Service Registration Object procedure.
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; import javax.xml.ws.BindingProvider; import com.vmware.vcloud.suite.lookup.LsService; import com.vmware.vcloud.suite.lookup.LsPortType; import com.vmware.vcloud.suite.lookup.ManagedObjectReference; import com.vmware.vcloud.suite.lookup.LookupServiceContent; ... String lookupServiceUrl; LsService lookupService; LsPortType lsPort; ManagedObjectReference serviceInstanceRef; LookupServiceContent lookupServiceContent; ManagedObjectReference serviceRegistration; //1 - Configure Lookup Service stub. HostnameVerifier hostVerifier = new HostnameVerifier (){ public boolean verify(String urlHostName, SSLSession session){ return true; } }; HttpsURLConnection.setDefaultHostnameVerifier(hostVerifier); SslUtil.trustAllHttpsCertificates(); //2 - Create the Lookup Service stub. lookupService = new LsService(); lsPort = new LsPorType.getLsPort(); ((BindingProvider)lsProvider).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, lookupServiceUrl); //4 - Create a predetermined management object. serviceInstanceRef = new ManagedObjectReference(); serviceInstanceRef.setType("LookupServiceInstance"); serviceInsanceRefl.setValue("ServiceInstance"); //5 - Retrieve the ServiceContent object. lookupServiceContent = lsPort.retrieveServiceContent(serviceInstanceRef); //6 - Retrieve the service registration serviceRegistration = lookupServiceContent.getServiceRegistration(); ...