Class: Handsoap::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/handsoap/service.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_body, soap_namespace) ⇒ Response

Returns a new instance of Response.



30
31
32
33
34
35
# File 'lib/handsoap/service.rb', line 30

def initialize(http_body, soap_namespace)
  @http_body = http_body
  @soap_namespace = soap_namespace
  @document = :lazy
  @fault = :lazy
end

Instance Method Details

#documentObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/handsoap/service.rb', line 39

def document
  if @document == :lazy
    begin
      @document = Handsoap::XmlQueryFront.parse_string(@http_body, Handsoap.xml_query_driver)
    rescue Handsoap::XmlQueryFront::ParseError => ex
      @document = nil
    end
  end
  return @document
end

#document?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/handsoap/service.rb', line 36

def document?
  !! document
end

#faultObject



52
53
54
55
56
57
58
# File 'lib/handsoap/service.rb', line 52

def fault
  if @fault == :lazy
    nodes = document? ? document.xpath('/env:Envelope/env:Body/descendant-or-self::env:Fault', { 'env' => @soap_namespace }) : []
    @fault = nodes.any? ? Fault.from_xml(nodes.first, :namespace => @soap_namespace) : nil
  end
  return @fault
end

#fault?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/handsoap/service.rb', line 49

def fault?
  !! fault
end