3

I'm not getting the expected results with the savon gem passing multiple parameters and giving them attributes.

Input:

message: {
        parameterId: 'timePeriod',       
        :query => [[:parameter=>{:@KeyId=>'geo', :@Value=>'528'}],
                  [:parameter=>{:@KeyId=>'timeType', :@Value=>'5'}]]     
      }

Actual output:

 <env:Body>
    <tns:DiscoverParameterValues>
      <tns:parameterId>timePeriod</tns:parameterId>
      <tns:query>
        <element>
          <parameter KeyId="geo" Value="528"/>
        </element>
      </tns:query>
      <tns:query>
        <element>
          <parameter KeyId="timeType" Value="5"/>
        </element>
      </tns:query>
    </tns:DiscoverParameterValues>
  </env:Body>
</env:Envelope> 

Expected output:

<env:Body>
    <tns:DiscoverParameterValues>
      <tns:parameterId>timePeriod</tns:parameterId>
      <tns:query>
          <parameter KeyId="geo" Value="528"/>
          <parameter KeyId="timeType" Value="5"/>
      </tns:query>
    </tns:DiscoverParameterValues>
  </env:Body>
</env:Envelope> 
wurde
  • 2,487
  • 2
  • 20
  • 39
Davidenko
  • 31
  • 1

1 Answers1

0

You want to make make an array of hashes. Savon will then replicate it for each item in the array.

query: {
  parameter: [
    {:@KeyId=>'geo', :@Value=>'528'}, 
    {:@KeyId=>'timeType', :@Value=>'5'}
  ]
}

I found this answer here - https://github.com/savonrb/savon/issues/713 Thanks you glennfu.

alex_milhouse
  • 891
  • 1
  • 13
  • 31