【问题标题】:How to generate repeating xml elements in Savon?如何在 Savon 中生成重复的 xml 元素?
【发布时间】:2013-06-27 14:09:48
【问题描述】:

soapUI 在它构建的请求 XML 的许多地方生成此注释 Zero or more repetitions。这是 XML 请求的一部分。

<v1:Attachments>
   <!--Zero or more repetitions:-->
       <v1:Attachment>
             <v1:FileName>?</v1:FileName>
             <v1:FileExtension>?</v1:FileExtension>
             <v1:FileContents>cid:1220950351678</v1:FileContents>
       </v1:Attachment>
 </v1:Attachments>

我正在使用 Savon 2.2.0 与外部服务进行通信。 Ruby hashes 需要唯一键。我尝试以

格式传递哈希数组
 attachments: [{attachment:
                {file_name: "foo1", 
                file_extension: "bar1", 
                 file_contents:"binary_encoded_content"}}, 
                {attachment:
                {file_name: "foo2", 
                 file_extension: "bar2", 
                 file_contents: "binary_encoded_content"}}]

但在这种情况下,Savon 只是在数组上执行to_s。我怎样才能做到这一点?

【问题讨论】:

    标签: ruby-on-rails soapui savon


    【解决方案1】:
    attachments: {
      attachment: [
        {
          file_name: "foo1", 
          file_extension: "bar1", 
          file_contents:"binary_encoded_content"
        }, 
        {
          file_name: "foo2", 
          file_extension: "bar2", 
          file_contents: "binary_encoded_content"
        }
      ]
    }
    

    等等。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-01
    • 1970-01-01
    • 2019-03-06
    • 2018-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多