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.



74
75
76
# File 'lib/savon/wsdl.rb', line 74

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.



118
119
# File 'lib/savon/wsdl.rb', line 118

def method_missing(method, *args)
end

Instance Attribute Details

#namespace_uriObject (readonly)

Returns the namespace URI.



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

def namespace_uri
  @namespace_uri
end

#operationsObject (readonly)

Returns the SOAP operations.



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

def operations
  @operations
end

#soap_endpointObject (readonly)

Returns the SOAP endpoint.



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

def soap_endpoint
  @soap_endpoint
end

Instance Method Details

#operation_from(tag, attrs) ⇒ Object

Stores available operations from a given tag name and attrs.



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/savon/wsdl.rb', line 105

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.



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

def tag_end(tag)
  @depth -= 1
end

#tag_start(tag, attrs) ⇒ Object

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



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

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
  @soap_endpoint ||= URI(attrs["location"]) if @section == :service && tag == "address"

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