我正在使用清除 gem ( https://github.com/inossidabile/wash_out ) 来公开 SOAP 服务。
洗出文档的示例用法如下所示:
# Params from XML attributes;
# e.g. for a request to the 'AddCircle' action:
# <soapenv:Envelope>
# <soapenv:Body>
# <AddCircle>
# <Circle radius="5.0">
# <Center x="10" y="12" />
# </Circle>
# </AddCircle>
# </soapenv:Body>
# </soapenv:Envelope>
soap_action "AddCircle",
:args => { :circle => { :center => { :@x => :integer,
:@y => :integer },
:@radius => :double } },
:return => nil, # [] for wash_out below 0.3.0
:to => :add_circle
def add_circle
circle = params[:circle]
Circle.new(circle[:center][:x], circle[:center][:y], circle[:radius])
render :soap => nil
end
但是我的 XML 请求有很多嵌套参数,我不想为每个 XML 属性定义映射 (:args)。有没有办法将 XML 请求 (XSD) 映射到 ruby 散列到需要作为 :args 用于肥皂动作的形式。