Class: Soap4juddi::Broker
- Inherits:
-
Object
- Object
- Soap4juddi::Broker
- Defined in:
- lib/soap4juddi/broker.rb
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#soap_connector ⇒ Object
readonly
Returns the value of attribute soap_connector.
-
#soap_xml ⇒ Object
readonly
Returns the value of attribute soap_xml.
-
#urns ⇒ Object
readonly
Returns the value of attribute urns.
Instance Method Summary collapse
- #authenticate(auth_user, auth_password) ⇒ Object
- #authorize ⇒ Object
- #delete_binding(binding) ⇒ Object
- #delete_business(key) ⇒ Object
- #delete_service_element(name, urn) ⇒ Object
- #find_business(pattern) ⇒ Object
- #find_element_bindings(name, urn) ⇒ Object
- #find_service_components(pattern) ⇒ Object
- #find_services(pattern, type = 'services') ⇒ Object
- #get_business(key) ⇒ Object
- #get_service_element(name, urn) ⇒ Object
-
#initialize(urns) ⇒ Broker
constructor
A new instance of Broker.
- #save_business(key, name, descriptions, contacts) ⇒ Object
- #save_element_bindings(service, bindings, urn, description) ⇒ Object
- #save_service_element(name, description, definition, urn, business_key) ⇒ Object
Constructor Details
#initialize(urns) ⇒ Broker
Returns a new instance of Broker.
11 12 13 14 15 |
# File 'lib/soap4juddi/broker.rb', line 11 def initialize(urns) @urns = urns @soap_connector = Soap4juddi::Connector.new @soap_xml = Soap4juddi::XML.new end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
9 10 11 |
# File 'lib/soap4juddi/broker.rb', line 9 def base_uri @base_uri end |
#soap_connector ⇒ Object (readonly)
Returns the value of attribute soap_connector.
7 8 9 |
# File 'lib/soap4juddi/broker.rb', line 7 def soap_connector @soap_connector end |
#soap_xml ⇒ Object (readonly)
Returns the value of attribute soap_xml.
8 9 10 |
# File 'lib/soap4juddi/broker.rb', line 8 def soap_xml @soap_xml end |
#urns ⇒ Object (readonly)
Returns the value of attribute urns.
6 7 8 |
# File 'lib/soap4juddi/broker.rb', line 6 def urns @urns end |
Instance Method Details
#authenticate(auth_user, auth_password) ⇒ Object
108 109 110 |
# File 'lib/soap4juddi/broker.rb', line 108 def authenticate(auth_user, auth_password) @soap_connector.authenticate(auth_user, auth_password) end |
#authorize ⇒ Object
112 113 114 |
# File 'lib/soap4juddi/broker.rb', line 112 def @auth_token = @soap_connector.(@base_uri) end |
#delete_binding(binding) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/soap4juddi/broker.rb', line 77 def delete_binding(binding) xml = @soap_xml.element_with_value('bindingKey', binding) @soap_connector.request_soap(@base_uri, 'publishv2', 'delete_binding', add_auth_body(xml)) do |res| { 'errno' => extract_errno(res.body) } end end |
#delete_business(key) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/soap4juddi/broker.rb', line 50 def delete_business(key) xml = @soap_xml.element_with_value('businessKey', key) @soap_connector.request_soap(@base_uri, 'publishv2', 'delete_business', add_auth_body(xml)) do |res| { 'errno' => extract_errno(res.body) } end end |
#delete_service_element(name, urn) ⇒ Object
101 102 103 104 105 106 |
# File 'lib/soap4juddi/broker.rb', line 101 def delete_service_element(name, urn) service_key = @soap_xml.element_with_value('serviceKey', "#{urn}#{name}") @soap_connector.request_soap(@base_uri, 'publishv2', 'delete_service', add_auth_body(service_key)) do |res| { 'errno' => extract_errno(res.body) } end end |
#find_business(pattern) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/soap4juddi/broker.rb', line 42 def find_business(pattern) qualifiers = @soap_xml.element_with_value('findQualifiers', @soap_xml.element_with_value('findQualifier', 'approximateMatch')) xml = @soap_xml.element_with_value('name', pattern) @soap_connector.request_soap(@base_uri, 'inquiryv2', 'find_business', "#{qualifiers} #{xml}") do |res| extract_business_entries(res.body) end end |
#find_element_bindings(name, urn) ⇒ Object
71 72 73 74 75 |
# File 'lib/soap4juddi/broker.rb', line 71 def find_element_bindings(name, urn) @soap_connector.request_soap(@base_uri, 'inquiryv2', 'get_serviceDetail', @soap_xml.element_with_value('serviceKey', "#{urn}#{name}")) do |res| extract_bindings(res.body) end end |
#find_service_components(pattern) ⇒ Object
67 68 69 |
# File 'lib/soap4juddi/broker.rb', line 67 def find_service_components(pattern) find_services(pattern, 'service-components') end |
#find_services(pattern, type = 'services') ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/soap4juddi/broker.rb', line 57 def find_services(pattern, type = 'services') qualifier1 = @soap_xml.element_with_value('findQualifier', 'approximateMatch') qualifier2 = @soap_xml.element_with_value('findQualifier', 'orAllKeys') qualifiers = @soap_xml.element_with_value('findQualifiers', "#{qualifier1}#{qualifier2}") xml = @soap_xml.element_with_value('name', pattern) @soap_connector.request_soap(@base_uri, 'inquiryv2', 'find_service', "#{qualifiers} #{xml}") do |res| extract_service_entries_elements(res.body, @urns[type]) end end |
#get_business(key) ⇒ Object
36 37 38 39 40 |
# File 'lib/soap4juddi/broker.rb', line 36 def get_business(key) @soap_connector.request_soap(@base_uri, 'inquiryv2', 'get_businessDetail', @soap_xml.element_with_value('businessKey', key)) do |res| extract_business(res.body) end end |
#get_service_element(name, urn) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/soap4juddi/broker.rb', line 84 def get_service_element(name, urn) key = name.include?(urn) ? name : "#{urn}#{name}" xml = @soap_xml.element_with_value('serviceKey', key) @soap_connector.request_soap(@base_uri, 'inquiryv2', 'get_serviceDetail', "#{xml}") do |res| { 'name' => extract_name(res.body), 'description' => extract_descriptions(res.body), 'definition' => extract_service_definition(res.body) } end end |
#save_business(key, name, descriptions, contacts) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/soap4juddi/broker.rb', line 25 def save_business(key, name, descriptions, contacts) validate_elements(contacts, 'contacts') validate_elements(descriptions, 'descriptions') body = build_business_entity(key, name, descriptions, contacts) @soap_connector.request_soap(@base_uri, 'publishv2', 'save_business', add_auth_body(body)) do | res| extract_business(res.body) end end |
#save_element_bindings(service, bindings, urn, description) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/soap4juddi/broker.rb', line 17 def save_element_bindings(service, bindings, urn, description) validate_elements(bindings, 'bindings') body = add_bindings("", service, bindings, urn, description) @soap_connector.request_soap(@base_uri, 'publishv2', 'save_binding', add_auth_body(body)) do | res| res.body end end |
#save_service_element(name, description, definition, urn, business_key) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/soap4juddi/broker.rb', line 94 def save_service_element(name, description, definition, urn, business_key) bindings = find_element_bindings_access_points(name, urn)['data']['result'] result = save_service_element_with_side_effect_which_clears_bindings(name, description, definition, urn, business_key) save_element_bindings(name, bindings, urn, '') result end |