The example is based on the code from the lookup_service_helper.rb sample file. The source file is located in the followingvCloud Suite SDK for Ruby directory: client/samples/lib/sample/common/

This example uses the steps that are described in the Connect to the Lookup Service and Retrieve the Service Registration Object procedure.

require 'rubygems'
require 'savon'
require 'builder'
# Create SOAP client object to communicate with the Lookup Service.
$my_ls_stub = Savon.client do |globals|
  globals.wsdl $wsdl_file
  globals.endpoint $ls_url
  globals.strip_namespaces false
  globals.env_namespace :S
  globals.ssl_verify_mode :none
end

# Create SOAP request with predetermined managed object reference.
builder = Builder::XmlMarkup.new()
builder.instruct!(:xml, encoding: 'UTF-8')
builder.tag!('S:Envelope', 
             'xmlns:S' =>
   'http://schemas.xmlsoap.org/soap/envelope/') do |envelope|
     envelope.tag!('S:Body') do |body|
       body.tag!('RetrieveServiceContent', 'xmlns' => 'urn:lookup') do |rsc|
         rsc.tag!('_this', 'type' => 'LookupServiceInstance') do |this|
           this << 'ServiceInstance'
         end
       end  # |rsc|
     end  # |body|
   end  # |envelope|
request = builder.target!.to_s
# Retrieve the ServiceContent object.
response = $my_ls_stub.call(:retrieve_service_content, xml:request)
lookup_service_content =
   response.to_hash[:retrieve_service_content_response][:returnval]

# Retrieve service registration.
service_registration = lookup_service_content[:service_registration]