web_service_scaffold (ActionWebService::Scaffolding::ClassMethods)

    # File lib/action_web_service/scaffolding.rb, line 41
          def web_service_scaffold(action_name)
            add_template_helper(Helpers)
            module_eval "def \#{action_name}\nif request.method == :get\nsetup_invocation_assigns\nrender_invocation_scaffold 'methods'\nend\nend\n\ndef \#{action_name}_method_params\nif request.method == :get\nsetup_invocation_assigns\nrender_invocation_scaffold 'parameters'\nend\nend\n\ndef \#{action_name}_submit\nif request.method == :post\nsetup_invocation_assigns\nprotocol_name = params['protocol'] ? params['protocol'].to_sym : :soap\ncase protocol_name\nwhen :soap\n@protocol = Protocol::Soap::SoapProtocol.create(self)\nwhen :xmlrpc\n@protocol = Protocol::XmlRpc::XmlRpcProtocol.create(self)\nend\nbm = Benchmark.measure do\n@protocol.register_api(@scaffold_service.api)\npost_params = params['method_params'] ? params['method_params'].dup : nil\nparams = []\n@scaffold_method.expects.each_with_index do |spec, i|\nparams << post_params[i.to_s]\nend if @scaffold_method.expects\nparams = @scaffold_method.cast_expects(params)\nmethod_name = public_method_name(@scaffold_service.name, @scaffold_method.public_name)\n@method_request_xml = @protocol.encode_request(method_name, params, @scaffold_method.expects)\nnew_request = @protocol.encode_action_pack_request(@scaffold_service.name, @scaffold_method.public_name, @method_request_xml)\nprepare_request(new_request, @scaffold_service.name, @scaffold_method.public_name)\n@request = new_request\nif @scaffold_container.dispatching_mode != :direct\nrequest.parameters['action'] = @scaffold_service.name\nend\ndispatch_web_service_request\n@method_response_xml = @response.body\nmethod_name, obj = @protocol.decode_response(@method_response_xml)\nreturn if handle_invocation_exception(obj)\n@method_return_value = @scaffold_method.cast_returns(obj)\nend\n@method_elapsed = bm.real\nadd_instance_variables_to_assigns\nreset_invocation_response\nrender_invocation_scaffold 'result'\nend\nend\n\nprivate\ndef setup_invocation_assigns\n@scaffold_class = self.class\n@scaffold_action_name = \"\#{action_name}\"\n@scaffold_container = WebServiceModel::Container.new(self)\nif params['service'] && params['method']\n@scaffold_service = @scaffold_container.services.find{ |x| x.name == params['service'] }\n@scaffold_method = @scaffold_service.api_methods[params['method']]\nend\nadd_instance_variables_to_assigns\nend\n\ndef render_invocation_scaffold(action)\ncustomized_template = \"\\\#{self.class.controller_path}/\#{action_name}/\\\#{action}\"\ndefault_template = scaffold_path(action)\nif template_exists?(customized_template)\ncontent = @template.render_file(customized_template)\nelse\ncontent = @template.render_file(default_template, false)\nend\n@template.instance_variable_set(\"@content_for_layout\", content)\nif self.active_layout.nil?\nrender_file(scaffold_path(\"layout\"))\nelse\nrender_file(self.active_layout, \"200 OK\", true)\nend\nend\n\ndef scaffold_path(template_name)\nFile.dirname(__FILE__) + \"/templates/scaffolds/\" + template_name + \".rhtml\"\nend\n\ndef reset_invocation_response\nerase_render_results\n@response.headers = ::ActionController::AbstractResponse::DEFAULT_HEADERS.merge(\"cookie\" => [])\nend\n\ndef public_method_name(service_name, method_name)\nif web_service_dispatching_mode == :layered && @protocol.is_a?(ActionWebService::Protocol::XmlRpc::XmlRpcProtocol)\nservice_name + '.' + method_name\nelse\nmethod_name\nend\nend\n\ndef prepare_request(new_request, service_name, method_name)\nnew_request.parameters.update(request.parameters)\nrequest.env.each{ |k, v| new_request.env[k] = v unless new_request.env.has_key?(k) }\nif web_service_dispatching_mode == :layered && @protocol.is_a?(ActionWebService::Protocol::Soap::SoapProtocol)\nnew_request.env['HTTP_SOAPACTION'] = \"/\\\#{controller_name()}/\\\#{service_name}/\\\#{method_name}\"\nend\nend\n\ndef handle_invocation_exception(obj)\nexception = nil\nif obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && obj.detail.cause.is_a?(Exception)\nexception = obj.detail.cause\nelsif obj.is_a?(XMLRPC::FaultException)\nexception = obj\nend\nreturn unless exception\nreset_invocation_response\nrescue_action(exception)\ntrue\nend\n", __FILE__, __LINE__
          end