0

我正在使用清除 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 用于肥皂动作的形式。

4

1 回答 1

0

如果不将每个嵌套属性一一映射到 ruby​​ 对象,我不知道有什么方法可以做到这一点,但是您可以尝试使用xml-mapping gem 并尝试测试您想要的。

于 2018-02-20T14:16:34.007 回答