Class: ServiceProxy::Parser

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Defined in:
lib/service_proxy/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Parser

Returns a new instance of Parser.



5
6
7
8
9
10
# File 'lib/service_proxy/parser.rb', line 5

def initialize(*args)
  self.service_methods = []
  self.soap_actions = Hash.new('')
  self.binding = false
  super
end

Instance Attribute Details

#bindingObject

Returns the value of attribute binding.



3
4
5
# File 'lib/service_proxy/parser.rb', line 3

def binding
  @binding
end

#service_methodsObject

Returns the value of attribute service_methods.



3
4
5
# File 'lib/service_proxy/parser.rb', line 3

def service_methods
  @service_methods
end

#soap_actionsObject

Returns the value of attribute soap_actions.



3
4
5
# File 'lib/service_proxy/parser.rb', line 3

def soap_actions
  @soap_actions
end

#soap_namespaceObject

Returns the value of attribute soap_namespace.



3
4
5
# File 'lib/service_proxy/parser.rb', line 3

def soap_namespace
  @soap_namespace
end

#target_namespaceObject

Returns the value of attribute target_namespace.



3
4
5
# File 'lib/service_proxy/parser.rb', line 3

def target_namespace
  @target_namespace
end

#wsdl_namespaceObject

Returns the value of attribute wsdl_namespace.



3
4
5
# File 'lib/service_proxy/parser.rb', line 3

def wsdl_namespace
  @wsdl_namespace
end

Instance Method Details

#end_element_namespace(name, prefix, uri) ⇒ Object



31
32
33
# File 'lib/service_proxy/parser.rb', line 31

def end_element_namespace(name, prefix, uri)
  self.binding = false if name == 'binding' && prefix == self.wsdl_namespace
end

#start_element_namespace(name, attributes, prefix, uri, namespace) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/service_proxy/parser.rb', line 12

def start_element_namespace(name, attributes, prefix, uri, namespace)
  case name
    when 'binding'
      self.binding = true
    when 'definitions'
      self.wsdl_namespace = prefix if uri == 'http://schemas.xmlsoap.org/wsdl/'
      self.soap_namespace = prefix if uri == 'http://schemas.xmlsoap.org/wsdl/soap/'
      attribute = attributes.find { |attribute| attribute.localname == 'targetNamespace' }
      self.target_namespace = attribute.value if attribute
    when "operation"
      if self.binding
        service_method = attributes.first.value if prefix == self.wsdl_namespace
        soap_action = attributes.find { |attribute| attribute.localname == 'soapAction' }
        self.soap_actions[self.service_methods.last] = soap_action.value if soap_action
        (self.service_methods << service_method unless self.service_methods.include?(service_method)) if service_method
      end
  end
end