Class: Savon::WSDLStream
Overview
Savon::WSDLStream
Savon::WSDLStream serves as a stream listener for parsing the WSDL document.
Constant Summary collapse
- Sections =
The main sections of a WSDL document.
%w(definitions types message portType binding service)
Instance Attribute Summary collapse
-
#namespace_uri ⇒ Object
readonly
Returns the namespace URI.
-
#operations ⇒ Object
readonly
Returns the SOAP operations.
-
#soap_endpoint ⇒ Object
readonly
Returns the SOAP endpoint.
Instance Method Summary collapse
-
#depth ⇒ Object
Returns our current depth in the WSDL document.
-
#initialize ⇒ WSDLStream
constructor
A new instance of WSDLStream.
-
#method_missing(method, *args) ⇒ Object
Catches calls to unimplemented hook methods.
-
#operation_from(tag, attrs) ⇒ Object
Stores available operations from a given tag
name
andattrs
. -
#read_namespaces(attrs) ⇒ Object
Reads namespace definitions from a given
attrs
Hash. -
#tag_end(tag) ⇒ Object
Hook method called when the stream parser encounters a closing tag.
-
#tag_start(tag, attrs) ⇒ Object
Hook method called when the stream parser encounters a starting tag.
Constructor Details
#initialize ⇒ WSDLStream
Returns a new instance of WSDLStream.
11 12 13 |
# File 'lib/savon/wsdl_stream.rb', line 11 def initialize @path, @operations, @namespaces = [], {}, {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Catches calls to unimplemented hook methods.
81 82 |
# File 'lib/savon/wsdl_stream.rb', line 81 def method_missing(method, *args) end |
Instance Attribute Details
#namespace_uri ⇒ Object (readonly)
Returns the namespace URI.
16 17 18 |
# File 'lib/savon/wsdl_stream.rb', line 16 def namespace_uri @namespace_uri end |
#operations ⇒ Object (readonly)
Returns the SOAP operations.
19 20 21 |
# File 'lib/savon/wsdl_stream.rb', line 19 def operations @operations end |
#soap_endpoint ⇒ Object (readonly)
Returns the SOAP endpoint.
22 23 24 |
# File 'lib/savon/wsdl_stream.rb', line 22 def soap_endpoint @soap_endpoint end |
Instance Method Details
#depth ⇒ Object
Returns our current depth in the WSDL document.
46 47 48 |
# File 'lib/savon/wsdl_stream.rb', line 46 def depth @path.size end |
#operation_from(tag, attrs) ⇒ Object
Stores available operations from a given tag name
and attrs
.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/savon/wsdl_stream.rb', line 68 def operation_from(tag, attrs) @input = attrs["name"] if attrs["name"] if attrs["soapAction"] @action = !attrs["soapAction"].blank? ? attrs["soapAction"] : @input @input = @action.split("/").last if !@input || @input.empty? @operations[@input.snakecase.to_sym] = { :action => @action, :input => @input } @input, @action = nil, nil end end |
#read_namespaces(attrs) ⇒ Object
Reads namespace definitions from a given attrs
Hash.
51 52 53 54 55 |
# File 'lib/savon/wsdl_stream.rb', line 51 def read_namespaces(attrs) attrs.each do |key, value| @namespaces[key.strip_namespace] = value if key.starts_with? "xmlns:" end end |
#tag_end(tag) ⇒ Object
Hook method called when the stream parser encounters a closing tag.
58 59 60 61 62 63 64 65 |
# File 'lib/savon/wsdl_stream.rb', line 58 def tag_end(tag) @path.pop if @section == :binding && @input && tag.strip_namespace == "operation" # no soapAction attribute found till now operation_from tag, "soapAction" => @input end end |
#tag_start(tag, attrs) ⇒ Object
Hook method called when the stream parser encounters a starting tag.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/savon/wsdl_stream.rb', line 25 def tag_start(tag, attrs) # read xml namespaces if root element read_namespaces(attrs) if @path.empty? tag, namespace = tag.split(":").reverse @path << tag if @section == :binding && tag == "binding" # ensure that we are in an wsdl/soap namespace @section = nil unless @namespaces[namespace].starts_with? "http://schemas.xmlsoap.org/wsdl/soap" end @section = tag.to_sym if Sections.include?(tag) && depth <= 2 @namespace_uri ||= attrs["targetNamespace"] if @section == :definitions @soap_endpoint ||= URI(attrs["location"]) if @section == :service && tag == "address" operation_from tag, attrs if @section == :binding && tag == "operation" end |