-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new SAX parser (much faster parsing)
- Loading branch information
1 parent
d970e36
commit 48d249b
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |