Skip to content

Commit

Permalink
Added new SAX parser (much faster parsing)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydurham committed Oct 26, 2009
1 parent d970e36 commit 48d249b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/service_proxy/parser.rb
@@ -0,0 +1,29 @@
module ServiceProxy
class Parser < Nokogiri::XML::SAX::Document
attr_accessor :wsdl_namespace, :soap_namespace, :target_namespace, :service_methods, :soap_actions

def initialize(*args)
self.service_methods = []
self.soap_actions = {}
super
end

def start_element_namespace(name, attributes, prefix, uri, namespace)
case name
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"
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

def end_element_namespace(name, prefix, uri)
end
end
end

0 comments on commit 48d249b

Please sign in to comment.