0

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与外部服务进行通信。Rubyhashes需要唯一的键。我尝试以格式传递一个哈希数组

 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在阵列上做 a。我怎样才能使这项工作?

4

1 回答 1

11
attachments: {
  attachment: [
    {
      file_name: "foo1", 
      file_extension: "bar1", 
      file_contents:"binary_encoded_content"
    }, 
    {
      file_name: "foo2", 
      file_extension: "bar2", 
      file_contents: "binary_encoded_content"
    }
  ]
}

等等。

于 2013-06-27T14:52:38.120 回答