In a SOAP Request, I need to specify repeated keys with different values like this:
soap.body = {:query => {
:fields => {
:string => 'Email',
:string => 'FirstName',
:string => 'LastName'
}
}
With this hash, the request will be formed 开发者_JAVA百科with:
<query><fields><string>LastName</string></fields></query>
The last :string pair. So if I put:
soap.body = {:query => {
:fields => "<string>Email</string>FirstName<string></string>LastName<string></string>"
}
This will result in:
<fields><string>Email</string><string>FirstName</string><string>LastName</string></fields>
Is there a way to get this in a hash?:
<query><fields><string>Email</string><string>FirstName</string><string>LastName</string></fields></query>
Note: I'm using Ruby 1.8.7.
Your first code cannot work and it's not Savon's fault, repeated keys in a hash are simply overriden. Did you try with an array?
soap.body = {
:query => {
:fields => {:string => ['Email', 'FirstName', 'LastName'],
}
}
Check also this: https://github.com/rubiii/savon/issues/45
精彩评论