Sha256: 81d0e26dd2388853ff52c716598cf907001ca2a40651e679f0cbad9d3c9ab155

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

module WashOut
  module Dispatcher
    def wsdl
      @map       = self.class.wash_with_soap_map
      @name      = controller_path.gsub('/', '_')
      @namespace = 'urn:WashOut'
      
      render :template => 'wash_with_soap/wsdl'
    end
    
    def soap
      @map     = self.class.wash_with_soap_map
      @method  = request.env['HTTP_SOAPACTION'].gsub(/^\"(.*)\"$/, '\1')
      @current = @map[@method] || @map[@method.to_sym]
      
      wash_out_error("Method does not exist") and return if @current.blank?
      
      data = Crack::XML.parse(request.raw_post).values.first.select{|k,v| k[-4,4] == "Body"}.values.first[@method]
      
      @soap   = @current[:in].load(data)
      @result = @current[:out].load(send @method.to_sym)
      
      render :template => 'wash_with_soap/response'
    end
    
  private
    
    def wash_out_error(description)
      @error = description and render :template => 'wash_with_soap/error'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wash_out-0.1 lib/wash_out/dispatcher.rb