Class: Savon::WSDLStream

Inherits:
Object show all
Defined in:
lib/savon/wsdl.rb

Overview

Savon::WSDLStream

Stream listener for parsing the WSDL document.

Constant Summary collapse

Sections =

Defines the main sections of a WSDL document.

%w(definitions types message portType binding service)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWSDLStream

Returns a new instance of WSDLStream.



61
62
63
# File 'lib/savon/wsdl.rb', line 61

def initialize
  @depth, @operations = 0, {}
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.



99
100
# File 'lib/savon/wsdl.rb', line 99

def method_missing(method, *args)
end

Instance Attribute Details

#namespace_uriObject (readonly)

Returns the namespace URI from the WSDL document.



66
67
68
# File 'lib/savon/wsdl.rb', line 66

def namespace_uri
  @namespace_uri
end

#operationsObject (readonly)

Returns the SOAP operations found in the WSDL document.



69
70
71
# File 'lib/savon/wsdl.rb', line 69

def operations
  @operations
end

Instance Method Details

#operation_from(tag, attrs) ⇒ Object

Stores available operations from a given tag name and attrs.



88
89
90
91
92
93
94
95
96
# File 'lib/savon/wsdl.rb', line 88

def operation_from(tag, attrs)
  @action = attrs["name"] if attrs["name"]

  if attrs["soapAction"]
    @action = attrs["soapAction"] unless attrs["soapAction"].blank?
    input = @action.split("/").last
    @operations[input.snakecase.to_sym] = { :action => @action, :input => input }
  end
end

#tag_end(tag) ⇒ Object

Hook method called when the stream parser encounters a closing tag.



83
84
85
# File 'lib/savon/wsdl.rb', line 83

def tag_end(tag)
  @depth -= 1
end

#tag_start(tag, attrs) ⇒ Object

Hook method called when the stream parser encounters a starting tag.



72
73
74
75
76
77
78
79
80
# File 'lib/savon/wsdl.rb', line 72

def tag_start(tag, attrs)
  @depth += 1
  tag = tag.strip_namespace

  @section = tag.to_sym if @depth <= 2 && Sections.include?(tag)
  @namespace_uri ||= attrs["targetNamespace"] if @section == :definitions

  operation_from tag, attrs if @section == :binding && tag == "operation"
end