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
How to Group Numbers into Different Buckets in Ruby
Initialize a Ruby Class from an Arbitrary Hash, But Only Keys with Matching Accessors
How to Use Activesupport::Configurable with Rails Engine
Exception_Notification for Delayed_Job
Using Activemodel::Serializer in Rails - JSON Data Differs Between JSON and Index Response
Log Doesn't Work in Production with Delayed Job
Rails Routes: Get Without Param :Id
In Ruby, How to Find Out If a String Is Not in an Array
Ruby -V Dyld: Library Not Loaded: /Usr/Local/Lib/Libgmp.10.Dylib
Create a Tempfile Without Opening It in Ruby
Deploy a Shell Script with Ruby Gem and Install in Bin Directory
How to Remove Blank Values Params from Query String
Get All Variables Defined Through 'Attr_Accessor' Without Overriding 'Attr_Accessor'
Loading Class Descendants in Rails Development
Problems Keeping an Object in an Array, Ruby Issues and Rails Issues