Вопрос

soapUI generates this comment Zero or more repetitions in many places in the request XML that it builds. This is part of the XML request.

<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>

I am using Savon 2.2.0 for communicating with the external service. Ruby hashes need unique keys. I tried passing an array of hashes in the format

 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"}}]

But in this case Savon just does a to_s on the array. How can I make this work?

Это было полезно?

Решение

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

Et voila.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top