How do I use savon nested attributes! hash?
You were close - just needed to put the :attributes!
key in the same hash that contains the value.
{
:person => {
:address => "",
:attributes! => { :address => { :id => 44 } }
},
:attributes! => { :person => { :id => 666 } }
}.to_soap_xml
# => "<person id=\"666\"><address id=\"44\"></address></person>"
How do I use savon nested array attributes! hash?
{
persons: {
person: [ { firstName: "JOHN", :@id => 1}, { firstName: "ANNIE", :@id => 2 } ]
}
}
Savon 2 how to add attribute to message_tag
You have to add the attribute to the call, eg.
client.call('CreateRequest', :attributes => { 'xmlns' => 'xyz' })
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"}
}]
}
}}
Savon array of hash
Bernardo,
the problem here is that your WSDL is RPC/Encoded (also indicated by the "soapenc" namespace prefix on the xs:restriction base attribute) and Savon version 3 (which is not officially released yet and only available via GitHub) does not support this style yet.
RPC/Encoded is rarely used but typically found with legacy systems. It defines a whole new type system which is not implemented right now. I'm still working out a proper type system
for XML Schema which is recommended for WSDL documents and that's already a lot of work. So I'm not sure when RPC/Encoded will be supported.
I would suggest you to use version 2 instead. Please make sure to follow the documentation, because version 2 works quite differently from version 3: http://savonrb.com/version2.html
Version 2 doesn't use much information from the WSDL, so you can choose to use it or not. You might need to try different options for this to work for your service (there are quite a few), but it should work.
Edit: I will change version 3 to raise an error for RPC/Encoded SOAP operations to make it obvious that this feature is currently not supported. Thank you.
Related Topics
Escape Single Quote in Xpath with Nokogiri
Why Can't I Use an Integer as a Key Using the New Ruby 1.9.2 Hash Syntax
How Does Require Rubygems Help Find Rubygem Files
301 Moved Permanently After S3 Uploading
How to Identify Aliased Methods in Ruby
Difference Between Downcase and Downcase! in Ruby
Error: While Executing Gem ... (Zlib::Gzipfile::Error) Not in Gzip Format
Travis Reports Odd Message of Corrupted Gemfile.Lock
Rails Active Admin CSS Conflicting with Twitter Bootstrap CSS
Ruby Ssl Error - Sslv3 Alert Unexpected Message
Functional Code Examples in Ruby