Class: Sem4rSoap::SoapResponse
- Inherits:
-
Object
- Object
- Sem4rSoap::SoapResponse
- Defined in:
- lib/sem4r_soap/soap_response.rb
Instance Attribute Summary collapse
-
#counters ⇒ Object
readonly
Returns the value of attribute counters.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
Instance Attribute Details
#counters ⇒ Object (readonly)
Returns the value of attribute counters.
30 31 32 |
# File 'lib/sem4r_soap/soap_response.rb', line 30 def counters @counters end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
29 30 31 |
# File 'lib/sem4r_soap/soap_response.rb', line 29 def response @response end |
Instance Method Details
#parse_response(response_xml) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/sem4r_soap/soap_response.rb', line 32 def parse_response(response_xml) # erase namespace so it more simple parsing the xml response_xml.gsub!(/\b(ns\d:|xsi:|s:|soapenv:|env:|soap:)/, "") response_xml.gsub!(/xmlns=["'].*?['"]/, '') @response = Nokogiri::XML::Document.parse(response_xml) # # extract information from header # header = @response.at_xpath("/Envelope/Header/ResponseHeader") # v2010xx if header @counters = { :operations => header.at_xpath("operations").text.to_i, :response_time => header.at_xpath("responseTime").text.to_i, :units => header.at_xpath("units").text.to_i } else header = @response.at_xpath("/Envelope/Header") # v13 if header @counters = { :operations => header.at_xpath("operations").text.to_i, :response_time => header.at_xpath("responseTime").text.to_i, :units => header.at_xpath("units").text.to_i } end end # # check soap fault # fault_el = @response.at_xpath("//Fault") if fault_el # fault_code = fault_el.at_xpath('faultcode').text # fault_string = fault_el.at_xpath('faultstring').text # raise SoapError, "#{fault_code}: '#{fault_string}'" fault_string = fault_el.at_xpath('faultstring').text @logger.error("soap error: #{fault_string}") if @logger raise fault_string end self end |