Class: WashOut::Middleware
- Inherits:
-
Object
- Object
- WashOut::Middleware
- Defined in:
- lib/wash_out/middleware.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
2 3 4 |
# File 'lib/wash_out/middleware.rb', line 2 def initialize app @app = app end |
Class Method Details
.raise_or_render_rexml_parse_error(e, env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wash_out/middleware.rb', line 14 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 |
.render_client_soap_fault(msg) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/wash_out/middleware.rb', line 29 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 |
Instance Method Details
#call(env) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/wash_out/middleware.rb', line 6 def call env begin @app.call env rescue REXML::ParseException => e self.class.raise_or_render_rexml_parse_error e, env end end |