Sha256: 68199af93acd0aea058092ada921cc17fffd28ac62598d17632fc4a14c013916

Contents?: true

Size: 1.18 KB

Versions: 19

Compression:

Stored size: 1.18 KB

Contents

class WashOut::Middleware
  def initialize app
    @app = app
  end

  def call env
    begin
      @app.call env
    rescue REXML::ParseException => e
      self.class.raise_or_render_rexml_parse_error e, env
    end
  end

  def self.raise_or_render_rexml_parse_error e, env
    raise e unless env.has_key? 'HTTP_SOAPACTION'
  
    # Normally input would be a StringIO, but Passenger has a different API:
    input = env['rack.input']
    req = if input.respond_to? :string then input.string else input.read end

    env['rack.errors'].puts <<-EOERR
WashOut::Exception: #{e.continued_exception} for:
#{req}
    EOERR
    [400, {'Content-Type' => 'text/xml'},
      [render_client_soap_fault("Error parsing SOAP Request XML")]]
  end

  def self.render_client_soap_fault msg
    xml = Builder::XmlMarkup.new
    xml.tag! 'soap:Envelope', 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' do
        xml.tag! 'soap:Body' do
          xml.tag! 'soap:Fault', :encodingStyle => 'http://schemas.xmlsoap.org/soap/encoding/' do
            xml.faultcode 'Client'
            xml.faultstring msg
          end
        end
      end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
wash-out-0.10.1 lib/wash_out/middleware.rb
wash_out-0.12.0 lib/wash_out/middleware.rb
wash_out-0.11.0 lib/wash_out/middleware.rb
wash_out-0.11.0.beta.2 lib/wash_out/middleware.rb
wash_out-0.11.0.beta.1 lib/wash_out/middleware.rb
wash_out-0.10.0 lib/wash_out/middleware.rb
wash_out-0.9.2 lib/wash_out/middleware.rb
wash_out-0.9.0 lib/wash_out/middleware.rb
wash_out-0.9.0.beta.2 lib/wash_out/middleware.rb
wash_out-0.9.0.beta.1 lib/wash_out/middleware.rb
wash_out-0.8.4 lib/wash_out/middleware.rb
wash_out-0.8.3 lib/wash_out/middleware.rb
wash_out-0.8.2 lib/wash_out/middleware.rb
wash_out-0.8.1 lib/wash_out/middleware.rb
wash_out-0.7.1 lib/wash_out/middleware.rb
wash_out-0.7.0 lib/wash_out/middleware.rb
wash_out-0.6.1 lib/wash_out/middleware.rb
wash_out-0.6.0 lib/wash_out/middleware.rb
wash_out-0.5.6 lib/wash_out/middleware.rb