2

当向 savon 提供:

hash = { 
              "Objects" => { //stuff here }, 
           :attributes! => { "Objects" => {"xsi:type" => "Something"}}
       }

我得到:

<Objects>...</Objects>

当为 savon 提供其他任何东西时,我得到了预期的结果:

hash = { 
         "foo" => { //stuff here }, 
         :attributes! => { "foo" => {"xsi:type" => "Something"}}
       }

我得到:

<foo xsi:type="Something"></foo>

我必须使用字符串“Objects”作为键。我正在编写第 3 方 SOAP Web 服务。我不能使用符号,因为第一个字母会变成小写字母。

谢谢,

4

1 回答 1

0

你必须改变 :attributes!到 :@xsi:type=>"Something" 在您想要属性的哈希中

喜欢:

"foo"=>{:@xsi:type=>'something', //stuff here}
于 2015-08-07T13:43:12.967 回答