How to Use Objects with Xsi:Types in Savon

How to use objects with xsi:types in Savon

Specifying XML attributes in a Hash is pretty ugly, but it's possible:

client.method_name do |soap|
soap.body = {
:parameter => 'value',
:attributes! => { :parameter => { 'xsi:type' => ValueClass } }
}
end

Please have a look at: http://github.com/rubiii/savon/wiki/SOAP

Until Savon supports XML Schema Attributes, I would suggest you to use Builder

(which comes with Savon) to generate your XML:

client.method_name do |soap|
xml = Builder::XmlMarkup.new
soap.body = xml.parameter "value", "xsi:type" => "ValueClass"
end

Savon | How to put different attributes in array of items

Finally I found this answer.

The hash has to be like this:

{Order: {
OrderItems: {
OrderItem: [{
Quantity: 1,
:'@code' => "AJF"}
},{
Quantity: 1,
:'@code' => "BUD"}
}]
}
}}


Related Topics



Leave a reply



Submit