Class: Soap4juddi::Connector
- Inherits:
-
Object
- Object
- Soap4juddi::Connector
- Includes:
- Jsender
- Defined in:
- lib/soap4juddi/connector.rb
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
-
#soap_xml ⇒ Object
readonly
Returns the value of attribute soap_xml.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #authenticate(auth_user, auth_password) ⇒ Object
- #authorize(base_uri) ⇒ Object
- #connection(base_uri, service, action) ⇒ Object
- #execute(req, &block) ⇒ Object
- #extract_auth_token(body) ⇒ Object
- #has_credentials? ⇒ Boolean
-
#initialize ⇒ Connector
constructor
A new instance of Connector.
- #request_soap(base_uri, version, service, request, attr = nil, &block) ⇒ Object
Constructor Details
#initialize ⇒ Connector
Returns a new instance of Connector.
12 13 14 |
# File 'lib/soap4juddi/connector.rb', line 12 def initialize @soap_xml = Soap4juddi::XML.new end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
10 11 12 |
# File 'lib/soap4juddi/connector.rb', line 10 def auth_token @auth_token end |
#soap_xml ⇒ Object (readonly)
Returns the value of attribute soap_xml.
9 10 11 |
# File 'lib/soap4juddi/connector.rb', line 9 def soap_xml @soap_xml end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
8 9 10 |
# File 'lib/soap4juddi/connector.rb', line 8 def uri @uri end |
Instance Method Details
#authenticate(auth_user, auth_password) ⇒ Object
21 22 23 24 |
# File 'lib/soap4juddi/connector.rb', line 21 def authenticate(auth_user, auth_password) @auth_user = auth_user @auth_password =auth_password end |
#authorize(base_uri) ⇒ Object
26 27 28 29 30 |
# File 'lib/soap4juddi/connector.rb', line 26 def (base_uri) validate_base_uri(base_uri) @auth_token = '' #clear existing auth token @auth_token = request_auth_token(base_uri) end |
#connection(base_uri, service, action) ⇒ Object
48 49 50 51 |
# File 'lib/soap4juddi/connector.rb', line 48 def connection(base_uri, service, action) validate_connection_parameters(base_uri, service, action) build_post_request(base_uri, service, action) end |
#execute(req, &block) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/soap4juddi/connector.rb', line 40 def execute(req, &block) validate_destination(req) res = Net::HTTP.start(@uri.hostname, @uri.port) do |http| http.request(req) end jsend_result(res, block) end |
#extract_auth_token(body) ⇒ Object
53 54 55 |
# File 'lib/soap4juddi/connector.rb', line 53 def extract_auth_token(body) (body.split('authtoken:')[1]).split('<')[0] end |
#has_credentials? ⇒ Boolean
16 17 18 19 |
# File 'lib/soap4juddi/connector.rb', line 16 def has_credentials? return true if @auth_user or @auth_password false end |
#request_soap(base_uri, version, service, request, attr = nil, &block) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/soap4juddi/connector.rb', line 32 def request_soap(base_uri, version, service, request, attr = nil, &block) req = connection(base_uri, version, service) req.body = @soap_xml.soap_envelope(request, service, attr) execute(req) do |res| block.call(res) end end |