Using multiple parameters with arguments with Savon stone

I am not getting the expected results when passing savon gem

multiple parameters and providing attributes to them.

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

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

      

+3


source to share


1 answer


You want to make an array of hashes. Savon then replicates it for each element 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 Thank you Glennfu.

0


source







All Articles