Class: Mongrel::SOAP4RHandler
- Inherits:
-
HttpHandler
- Object
- HttpHandler
- Mongrel::SOAP4RHandler
- Defined in:
- lib/mongrel/soap4r.rb
Constant Summary collapse
- POST =
"POST".freeze
- ALLOW =
"Allow".freeze
- MONGREL_CONTENT_TYPE =
"HTTP_CONTENT_TYPE".freeze
- MONGREL_SOAP_ACTION =
"HTTP_SOAPACTION".freeze
Instance Method Summary collapse
-
#initialize(router = nil) ⇒ SOAP4RHandler
constructor
A new instance of SOAP4RHandler.
- #process(request, response) ⇒ Object
Constructor Details
#initialize(router = nil) ⇒ SOAP4RHandler
Returns a new instance of SOAP4RHandler.
17 18 19 |
# File 'lib/mongrel/soap4r.rb', line 17 def initialize(router = nil) @router = router || ::SOAP::RPC::Router.new(self.class.name) end |
Instance Method Details
#process(request, response) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mongrel/soap4r.rb', line 21 def process(request, response) req_method = request.params[Const::REQUEST_METHOD] if req_method != POST response.start(405) do |head,out| head[ALLOW] = POST out.write(HTTP_STATUS_CODES[405]) end return end begin conn_data = ::SOAP::StreamHandler::ConnectionData.new setup_req(conn_data, request) conn_data = @router.route(conn_data) status = conn_data.is_fault ? 500 : 200 response.start(status) do |head,out| head[Const::CONTENT_TYPE] = conn_data.send_contenttype out.write(conn_data.send_string) end rescue Exception => e conn_data = @router.create_fault_response(e) response.start(500) do |head,out| head[Const::CONTENT_TYPE] = conn_data.send_contenttype || "text/xml" out.write(conn_data.send_string) end end end |