3

Here is my problem: One of our client wants to access soap actions with passing action_name in query string. Is it possible to do it with wash_out gem?

example url: http://example.com/dummy_soap/action?action_name=do_something

Any help is appreciated.

emrahbasman
  • 2,003
  • 10
  • 19

1 Answers1

2

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

infused
  • 24,000
  • 13
  • 68
  • 78