Class: Uddi4r::Connection

Inherits:
Object
  • Object
show all
Includes:
SoapBuilder
Defined in:
lib/uddi4r/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”



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

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



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

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)



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

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)



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

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



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

def max_rows=(max_rows)
  @max_rows = max_rows
end

#to_sObject



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

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