Class: SOAP::WSDL::Binding

Inherits:
Object
  • Object
show all
Defined in:
lib/soap/lc/wsdl/binding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ Binding

Returns a new instance of Binding.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/soap/lc/wsdl/binding.rb', line 36

def initialize( element )
  @operations = Hash.new
  @name = element.attributes['name']
  @type = element.attributes['type'] # because of Object#type
  @style = nil
  @transport = nil
  
  # Process all binding and operation
  element.find_all {|e| e.class == REXML::Element }.each { |operation|
    case operation.name
      when "binding"
        # Get binding attributs
        operation.attributes.each { |name, value|
          case name
            when 'style'
              @style = value
            when 'transport'
              @transport = value
            else
              warn "Ignoring attribut `#{name}' for wsdlsoap:binding in binding `#{element.attributes['name']}'"
          end
        }
      when "operation"
        # Store operations
        @operations[operation.attributes['name']] = Hash.new()
        
        # Get operation attributs
        operation.attributes.each { |name, value|
          case name
            when 'name'
              @operations[operation.attributes['name']][:name] = value
            else
              warn "Ignoring attribut `#{name}' for operation `#{operation.attributes['name']}' in binding `#{element.attributes['name']}'"
          end
        }
        
        # Store operation input, output, fault and operation
        operation.find_all {|e| e.class == REXML::Element }.each { |action|
          case action.name
            when "operation"
              # Get operation attributs
              action.attributes.each { |name, value|
                case name
                  when 'soapAction'
                    @operations[operation.attributes['name']][:soapAction] = value
                  when 'style'
                    @operations[operation.attributes['name']][:style] = value
                  else
                    warn "Ignoring attribut `#{name}' for wsdlsoap:operation in operation `#{operation.attributes['name']}' in binding `#{element.attributes['name']}'"
                end
              }
            when "input"
              @operations[operation.attributes['name']][:input] = Hash.new
              
              # Store input attributs
              action.attributes.each { |name, value|
                case name
                  when 'name'
                    @operations[operation.attributes['name']][:input][:name] = value
                  else
                    warn "Ignoring attribut `#{name}' in #{action.name} `#{action.attributes['name']}' in operation `#{operation.attributes['name']}' for binding `#{element.attributes['name']}'"
                end
              }
              
              # Store body 
              action.find_all {|e| e.class == REXML::Element }.each { |body|
                case body.name
                  when "body"
                    @operations[operation.attributes['name']][:input][:body] = Hash.new
                    
                    # Store body attributes
                    body.attributes.each { |name, value|
                      @operations[operation.attributes['name']][:input][:body][name.to_sym] = value
                    }
                  else
                    warn "Ignoring element `#{body.name}' in #{action.name} `#{action.attributes['name']}' in operation `#{operation.attributes['name']}' for binding `#{element.attributes['name']}'"
                end
              }
            when "output"
              @operations[operation.attributes['name']][:output] = Hash.new
              
              # Store input attributs
              action.attributes.each { |name, value|
                case name
                  when 'name'
                    @operations[operation.attributes['name']][:output][:name] = value
                  else
                    warn "Ignoring attribut `#{name}' in #{action.name} `#{action.attributes['name']}' in operation `#{operation.attributes['name']}' for binding `#{element.attributes['name']}'"
                end
              }
              
              # Store body 
              action.find_all {|e| e.class == REXML::Element }.each { |body|
                case body.name
                  when "body"
                    @operations[operation.attributes['name']][:output][:body] = Hash.new
                    
                    # Store body attributes
                    body.attributes.each { |name, value|
                      @operations[operation.attributes['name']][:output][:body][name.to_sym] = value
                    }
                  else
                    warn "Ignoring element `#{body.name}' in #{action.name} `#{action.attributes['name']}' in operation `#{operation.attributes['name']}' for binding `#{element.attributes['name']}'"
                end
              }
            when "fault"
              @operations[operation.attributes['name']][:fault] = Hash.new
              
              # Store input attributs
              action.attributes.each { |name, value|
                case name
                  when 'name'
                    @operations[operation.attributes['name']][:fault][:name] = value
                  else
                    warn "Ignoring attribut `#{name}' in #{action.name} `#{action.attributes['name']}' in operation `#{operation.attributes['name']}' for binding `#{element.attributes['name']}'"
                end
              }
              
              # Store body 
              action.find_all {|e| e.class == REXML::Element }.each { |body|
                case body.name
                  when "body"
                    @operations[operation.attributes['name']][:fault][:body] = Hash.new
                    
                    # Store body attributes
                    body.attributes.each { |name, value|
                      @operations[operation.attributes['name']][:fault][:body][name.to_sym] = value
                    }
                  else
                    warn "Ignoring element `#{body.name}' in #{action.name} `#{action.attributes['name']}' in operation `#{operation.attributes['name']}' for binding `#{element.attributes['name']}'"
                end
              }                    
            else
              warn "Ignoring element `#{action.name}' in operation `#{operation.attributes['name']}' for binding `#{element.attributes['name']}'"
          end
        }
      else
        warn "Ignoring element `#{operation.name}' in binding `#{element.attributes['name']}'"
    end
  }
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



31
32
33
# File 'lib/soap/lc/wsdl/binding.rb', line 31

def name
  @name
end

#operationsObject (readonly)

Returns the value of attribute operations.



30
31
32
# File 'lib/soap/lc/wsdl/binding.rb', line 30

def operations
  @operations
end

#styleObject (readonly)

Returns the value of attribute style.



33
34
35
# File 'lib/soap/lc/wsdl/binding.rb', line 33

def style
  @style
end

#transportObject (readonly)

Returns the value of attribute transport.



34
35
36
# File 'lib/soap/lc/wsdl/binding.rb', line 34

def transport
  @transport
end

#typeObject (readonly)

Returns the value of attribute type.



32
33
34
# File 'lib/soap/lc/wsdl/binding.rb', line 32

def type
  @type
end