The example is based on the code from the LsConnection.cs sample file. The source 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 Connect to the Lookup Service and Retrieve the Service Registration Object procedure.
using System; using System.ServiceModel; using System.ServiceModel.Channels; using vmware.lookupservice; // 1 - Create a custom binding for SOAP messages. var customBinding = new CustomBinding(); var textMessageEncoding = new TextMessageEncodingBindingElement(); textMessageEncoding.MessageVersion = MessageVersion.Soap11; var transport = new HttpsTransportBindingElement(); transport.MaxReceivedMessageSize = 2147483647; customBinding.Elements.Add(textMessageEncoding); customBinding.Elements.Add(transport); // 2 - Create an object that encapsulates the Lookup Service URL. var address = new EndpointAddress(lsUrl); // 3 - Create a connection object to communicate with the Lookup Service. lsPort = new LsPortTypeClient(customBinding, address); // 4 - Manufacture a managed object reference. var serviceInstanceRef = new ManagedObjectReference(); serviceInstanceRef.type = "LookupServiceInstance"; serviceInstanceRef.Value = "ServiceInstance"; // 5 - Retrieve the ServiceContent managed object. serviceContent = lsPort.RetrieveServiceContent(serviceInstanceRef); // 6 - Retrieve the service registration object. serviceRegistration = serviceContent.serviceRegistration;