Class: Uddi4r::Connection

Inherits:
Object
  • Object
show all
Includes:
SoapBuilder
Defined in:
lib/connection.rb

Overview

Connection

This class manages the UDDI connection and SOAP messaging. It also provides helper methods for creating SOAP payload and related XML elements.

Example

Following example demonstrates the typical browse use-case for UDDI. It starts with the findBusiness use-case and drills down to the specific binding.

uddi = Uddi4r::UddiClient.new(XMethodsUddi.url)
biz = uddi.find_business("chaiwat").first
service = biz.service_infos.first
binding = uddi.find_binding(service.service_key)

Constant Summary collapse

@@XmlNamespace =
{"2.0"=>"urn:uddi-org:api_v2"}

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SoapBuilder

#create_body, #create_element, #create_elements, #create_operation, #create_payload, #create_t_model_bag, #create_uddi_operation

Constructor Details

#initialize(endpoint, version = "2.0", debug = false) ⇒ Connection

Create the UDDI connection for given endpoint and protocol version.

endpoint

URL to UDDI server as string

version

UDDI protocol version as string. Default (and only support) is “2.0”



34
35
36
37
38
39
40
41
42
# File 'lib/connection.rb', line 34

def initialize(endpoint, version="2.0", debug=false)
  @endpoint = endpoint
  @version = version.to_s()
  @uddi_namespace = Connection.namespace_for(@version)
  props = SOAP::Property.new()
  props["wiredump_dev"] = STDOUT if debug
  @stream_handler = SOAP::HTTPStreamHandler.new(props)
  @max_rows = nil
end

Class Method Details

.namespace_for(version) ⇒ Object

Returns fully qualified namespace for given UDDI protocol version



45
46
47
# File 'lib/connection.rb', line 45

def self.namespace_for(version)
  return @@XmlNamespace[version.to_s()] || raise("Unsupported UDDI version #{version}")
end

Instance Method Details

#invoke(payload) ⇒ Object

Uses the connection to transmit given payload (DOM element)



63
64
65
66
67
68
# File 'lib/connection.rb', line 63

def invoke(payload)
  return puts(payload) unless @endpoint
  data = SOAP::StreamHandler::ConnectionData.new(payload.to_s())
  response = @stream_handler.send(@endpoint, data).receive_string
  return REXML::Document.new(response)
end

#invoke_operation(operation) ⇒ Object

Uses the connection to invoke SOAP call for given operation (DOM element)



55
56
57
58
59
60
# File 'lib/connection.rb', line 55

def invoke_operation(operation)
  body = create_body()
  body << operation
  payload = create_payload(body)
  invoke(payload)
end

#max_rows=(max_rows) ⇒ Object

Set the maximum rows returns by the UDDI server



50
51
52
# File 'lib/connection.rb', line 50

def max_rows=(max_rows)
  @max_rows = max_rows
end

#to_sObject



70
71
72
# File 'lib/connection.rb', line 70

def to_s
  "UDDI connection: #{@endpoint}: #{@version} ns:#{@uddi_namespace}"
end