Method: Wasabi::Parser#parse_operations

Defined in:
lib/wasabi/parser.rb

#parse_operationsObject



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
# File 'lib/wasabi/parser.rb', line 138

def parse_operations
  operations = document.xpath('wsdl:definitions/wsdl:binding/wsdl:operation', 'wsdl' => WSDL)
  operations.each do |operation|
    name = operation.attribute('name').to_s
    snakecase_name = Wasabi::CoreExt::String.snakecase(name).to_sym

    # TODO: check for soap namespace?
    soap_operation = operation.element_children.find { |node| node.name == 'operation' }
    soap_action = soap_operation['soapAction'] if soap_operation
    soap_document = soap_operation['style'] == 'document'  if soap_operation

    if soap_action || soap_document
      soap_action = soap_action.to_s
      action = soap_action && !soap_action.empty? ? soap_action : name

      # There should be a matching portType for each binding, so we will lookup the input from there.
      namespace_id, output = output_for(operation)
      namespace_id, input = input_for(operation)

      # Store namespace identifier so this operation can be mapped to the proper namespace.
      @operations[snakecase_name] = { :action => action, :input => input, :output => output, :namespace_identifier => namespace_id}
    elsif !@operations[snakecase_name]
      @operations[snakecase_name] = { :action => name, :input => name }
    end
  end
end