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 =

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.



79
80
81
82
# File 'lib/savon/wsdl.rb', line 79

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



130
131
# File 'lib/savon/wsdl.rb', line 130

def method_missing(method, *args)
end

Instance Attribute Details

#namespace_uriObject (readonly)

Returns the namespace URI.



85
86
87
# File 'lib/savon/wsdl.rb', line 85

def namespace_uri
  @namespace_uri
end

#operationsObject (readonly)

Returns the SOAP operations.



88
89
90
# File 'lib/savon/wsdl.rb', line 88

def operations
  @operations
end

#sectionsObject (readonly)

Visited sections (used to check validaty of the WSDL)



94
95
96
# File 'lib/savon/wsdl.rb', line 94

def sections
  @sections
end

#soap_endpointObject (readonly)

Returns the SOAP endpoint.



91
92
93
# File 'lib/savon/wsdl.rb', line 91

def soap_endpoint
  @soap_endpoint
end

Instance Method Details

#operation_from(tag, attrs) ⇒ Object

Stores available operations from a given tag name and attrs.



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/savon/wsdl.rb', line 117

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

#tag_end(tag) ⇒ Object

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



112
113
114
# File 'lib/savon/wsdl.rb', line 112

def tag_end(tag)
  @depth -= 1
end

#tag_start(tag, attrs) ⇒ Object

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



97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/savon/wsdl.rb', line 97

def tag_start(tag, attrs)
  @depth += 1
  tag = tag.strip_namespace
  
  if @depth <= 2 && Sections.include?(tag)
    @section = tag.to_sym
    @sections << @section
  end
  @namespace_uri ||= attrs["targetNamespace"] if @section == :definitions
  @soap_endpoint ||= URI(URI.escape(attrs["location"])) if @section == :service && tag == "address"

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