JavaEar 专注于收集分享传播有价值的技术资料

1个回答

    最佳答案

  1. 英文原文

    It is possible. Use send to call the action that you want. Note that this will only work if the other action explicitly calls render at the end of the action. Also, do not trust the :action_name param. Consider checking the :action_name against a whitelist of allowed actions before using it and raise an error if it's invalid.

    class DummySoapController < ApplicationController
      soap_service namespace: 'urn:WashOut'
    
      def action
        send(params[:action_name])
      end
    
      soap_action "convert_to_string", :args => :integer, :return => :string
    
      def convert_to_string
        render :soap => params[:value].to_s
      end
    
      soap_action "convert_to_integer", :args => :integer, :return => :float
    
      def convert_to_float
        render :soap => params[:value].to_f
      end
    
    end
    

    For example, to get a string value you would use the URL

    http://example.com/dummy_soap/action?action_name=convert_to_string&value=1

    Or to get a float

    http://example.com/dummy_soap/action?action_name=convert_to_float&value=1


    中文翻译

    有可能。使用 send 来调用所需的操作。请注意,这仅在其他操作在操作结束时显式调用 render 时才有效。另外,不要信任:action_name param。在使用之前,请考虑针对允许操作的白名单检查:action_name,如果无效则引发错误。

      class DummySoapController&lt; ApplicationController的
      soap_service命名空间:'urn:WashOut'
    
      def行动
        发送(PARAMS [:ACTION_NAME])
      结束
    
      soap_action" convert_to_string" ,:args =&gt; :integer,:return =&gt; :串
    
      def convert_to_string
        渲染:soap =&gt; PARAMS [:值] .to_s
      结束
    
      soap_action" convert_to_integer" ,:args =&gt; :integer,:return =&gt; :浮动
    
      def convert_to_float
        渲染:soap =&gt; PARAMS [:值] .to_f
      结束
    
    结束
     

    例如,要获取字符串值,您将使用URL

    http://example.com/dummy_soap/action?action_name=convert_to_string&值= 1个

    或者获得一个浮动

    http://example.com/dummy_soap/action?action_name=convert_to_float&值= 1个

    It is possible. Use send to call the action that you want. Note that this will only work if the other action explicitly calls render at the end of the action. Also, do not trust the :action_name param. Consider checking the :action_name against a whitelist of allowed actions before using it and raise an error if it's invalid.

    class DummySoapController < ApplicationController
      soap_service namespace: 'urn:WashOut'
    
      def action
        send(params[:action_name])
      end
    
      soap_action "convert_to_string", :args => :integer, :return => :string
    
      def convert_to_string
        render :soap => params[:value].to_s
      end
    
      soap_action "convert_to_integer", :args => :integer, :return => :float
    
      def convert_to_float
        render :soap => params[:value].to_f
      end
    
    end
    

    For example, to get a string value you would use the URL

    http://example.com/dummy_soap/action?action_name=convert_to_string&value=1

    Or to get a float

    http://example.com/dummy_soap/action?action_name=convert_to_float&value=1

    有可能。使用 send 来调用所需的操作。请注意,这仅在其他操作在操作结束时显式调用 render 时才有效。另外,不要信任:action_name param。在使用之前,请考虑针对允许操作的白名单检查:action_name,如果无效则引发错误。

      class DummySoapController&lt; ApplicationController的
      soap_service命名空间:'urn:WashOut'
    
      def行动
        发送(PARAMS [:ACTION_NAME])
      结束
    
      soap_action" convert_to_string" ,:args =&gt; :integer,:return =&gt; :串
    
      def convert_to_string
        渲染:soap =&gt; PARAMS [:值] .to_s
      结束
    
      soap_action" convert_to_integer" ,:args =&gt; :integer,:return =&gt; :浮动
    
      def convert_to_float
        渲染:soap =&gt; PARAMS [:值] .to_f
      结束
    
    结束
     

    例如,要获取字符串值,您将使用URL

    http://example.com/dummy_soap/action?action_name=convert_to_string&值= 1个

    或者获得一个浮动

    http://example.com/dummy_soap/action?action_name=convert_to_float&值= 1个