Class: RhoconnectAdapters::SoapService
- Inherits:
-
Object
- Object
- RhoconnectAdapters::SoapService
- Defined in:
- lib/rhoconnect-adapters/soap_service.rb
Class Attribute Summary collapse
-
.envelope_namespaces ⇒ Object
use envelope namespaces to be passed with the SOAP request.
-
.node_namespaces ⇒ Object
use node_namespaces attribute to specify namespaces used by SoapService’s select_node and select_node_text methods.
Class Method Summary collapse
- .compose_message(header, body, namespaces = RhoconnectAdapters::SoapService.envelope_namespaces) ⇒ Object
- .compose_wsse_header(username, password) ⇒ Object
- .select_node(doc, node_name) ⇒ Object
- .select_node_text(doc, node_name) ⇒ Object
- .send_request(endpoint, message, action = nil, content_type = 'text/xml; charset=UTF-8', cookie = nil) ⇒ Object
- .send_request_raw(endpoint, message, action = nil, content_type = 'text/xml; charset=UTF-8', cookie = nil) ⇒ Object
Class Attribute Details
.envelope_namespaces ⇒ Object
use envelope namespaces to be passed with the SOAP request
22 23 24 |
# File 'lib/rhoconnect-adapters/soap_service.rb', line 22 def envelope_namespaces @envelope_namespaces end |
.node_namespaces ⇒ Object
use node_namespaces attribute to specify namespaces used by SoapService’s select_node and select_node_text methods
20 21 22 |
# File 'lib/rhoconnect-adapters/soap_service.rb', line 20 def node_namespaces @node_namespaces end |
Class Method Details
.compose_message(header, body, namespaces = RhoconnectAdapters::SoapService.envelope_namespaces) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/rhoconnect-adapters/soap_service.rb', line 41 def (header,body,namespaces=RhoconnectAdapters::SoapService.envelope_namespaces) hdr = header ? "<s:Header>#{header}</s:Header>" : "" bdy = body ? "<s:Body>#{body}</s:Body>" : "" "<?xml version=\"1.0\"?> <s:Envelope #{namespaces}> #{hdr} #{bdy} </s:Envelope>" end |
.compose_wsse_header(username, password) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/rhoconnect-adapters/soap_service.rb', line 32 def compose_wsse_header(username,password) "<wsse:Security> <wsse:UsernameToken wsu:Id=\"UsernameToken-1\"> <wsse:Username>#{username}</wsse:Username> <wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">#{password}</wsse:Password> </wsse:UsernameToken> </wsse:Security>" end |
.select_node(doc, node_name) ⇒ Object
24 25 26 |
# File 'lib/rhoconnect-adapters/soap_service.rb', line 24 def select_node(doc,node_name) doc.xpath("#{node_name}",SoapService.node_namespaces) end |
.select_node_text(doc, node_name) ⇒ Object
28 29 30 |
# File 'lib/rhoconnect-adapters/soap_service.rb', line 28 def select_node_text(doc,node_name) doc.xpath("#{node_name}/text()",SoapService.node_namespaces).to_s.strip end |
.send_request(endpoint, message, action = nil, content_type = 'text/xml; charset=UTF-8', cookie = nil) ⇒ Object
51 52 53 54 |
# File 'lib/rhoconnect-adapters/soap_service.rb', line 51 def send_request(endpoint,,action=nil,content_type='text/xml; charset=UTF-8',=nil) response = send_request_raw(endpoint, , action, content_type, ) Nokogiri::XML(response) end |
.send_request_raw(endpoint, message, action = nil, content_type = 'text/xml; charset=UTF-8', cookie = nil) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rhoconnect-adapters/soap_service.rb', line 56 def send_request_raw(endpoint,,action=nil,content_type='text/xml; charset=UTF-8',=nil) begin headers = { :content_type => content_type } headers.merge!({ "SOAPAction" => action }) if action headers.merge!({ "Cookie" => }) if response = RestClient.post(endpoint, , headers) rescue RestClient::Exception => ex warn "#{self.name} error: " + ex.inspect.strip ex.backtrace.each { |line| warn 'from ' + line } raise ex end end |