diff options
Diffstat (limited to 'actionwebservice')
-rw-r--r-- | actionwebservice/CHANGELOG | 2 | ||||
-rw-r--r-- | actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb | 35 | ||||
-rw-r--r-- | actionwebservice/test/abstract_client.rb | 9 | ||||
-rw-r--r-- | actionwebservice/test/abstract_unit.rb | 7 | ||||
-rw-r--r-- | actionwebservice/test/client_soap_test.rb | 7 | ||||
-rw-r--r-- | actionwebservice/test/client_xmlrpc_test.rb | 7 |
6 files changed, 46 insertions, 21 deletions
diff --git a/actionwebservice/CHANGELOG b/actionwebservice/CHANGELOG index ebbb975501..9f6abfdc5d 100644 --- a/actionwebservice/CHANGELOG +++ b/actionwebservice/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix soap type registration of multidimensional arrays (#4232) + * Fix that marshaler couldn't handle ActiveRecord models defined in a different namespace (#2392). * Fix that marshaler couldn't handle structs with members of ActiveRecord type (#1889). diff --git a/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb b/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb index fa917ad4a5..351c9da159 100644 --- a/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb +++ b/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb @@ -40,32 +40,25 @@ module ActionWebService def register_type(type) return @type2binding[type] if @type2binding.has_key?(type) - type_class = type.array?? type.element_type.type_class : type.type_class - type_type = type.array?? type.element_type : type - type_binding = nil - if (mapping = @registry.find_mapped_soap_class(type_class) rescue nil) - qname = mapping[2] ? mapping[2][:type] : nil - qname ||= soap_base_type_name(mapping[0]) - type_binding = SoapBinding.new(self, qname, type_type, mapping) - else - qname = XSD::QName.new(@namespace, soap_type_name(type_class.name)) - @registry.add(type_class, - SOAP::SOAPStruct, - typed_struct_factory(type_class), - { :type => qname }) - mapping = @registry.find_mapped_soap_class(type_class) - type_binding = SoapBinding.new(self, qname, type_type, mapping) - end - - array_binding = nil if type.array? array_mapping = @registry.find_mapped_soap_class(Array) qname = XSD::QName.new(@namespace, soap_type_name(type.element_type.type_class.name) + 'Array') - array_binding = SoapBinding.new(self, qname, type, array_mapping, type_binding) + element_type_binding = register_type(type.element_type) + @type2binding[type] = SoapBinding.new(self, qname, type, array_mapping, element_type_binding) + elsif (mapping = @registry.find_mapped_soap_class(type.type_class) rescue nil) + qname = mapping[2] ? mapping[2][:type] : nil + qname ||= soap_base_type_name(mapping[0]) + @type2binding[type] = SoapBinding.new(self, qname, type, mapping) + else + qname = XSD::QName.new(@namespace, soap_type_name(type.type_class.name)) + @registry.add(type.type_class, + SOAP::SOAPStruct, + typed_struct_factory(type.type_class), + { :type => qname }) + mapping = @registry.find_mapped_soap_class(type.type_class) + @type2binding[type] = SoapBinding.new(self, qname, type, mapping) end - @type2binding[type] = array_binding ? array_binding : type_binding - if type.structured? type.each_member do |m_name, m_type| register_type(m_type) diff --git a/actionwebservice/test/abstract_client.rb b/actionwebservice/test/abstract_client.rb index c5484b6b62..5207d8ef21 100644 --- a/actionwebservice/test/abstract_client.rb +++ b/actionwebservice/test/abstract_client.rb @@ -34,6 +34,10 @@ module ClientTest member :user, User member :users, [User] end + + class WithMultiDimArray < ActionWebService::Struct + member :pref, [[:string]] + end class API < ActionWebService::API::Base api_method :void @@ -48,6 +52,7 @@ module ClientTest api_method :user_return, :returns => [User] api_method :with_model_return, :returns => [WithModel] api_method :scoped_model_return, :returns => [Accounting::User] + api_method :multi_dim_return, :returns => [WithMultiDimArray] end class NullLogOut @@ -124,6 +129,10 @@ module ClientTest def scoped_model_return Accounting::User.find(1) end + + def multi_dim_return + WithMultiDimArray.new :pref => [%w{pref1 value1}, %w{pref2 value2}] + end end class AbstractClientLet < WEBrick::HTTPServlet::AbstractServlet diff --git a/actionwebservice/test/abstract_unit.rb b/actionwebservice/test/abstract_unit.rb index 149f108c98..6862d222e4 100644 --- a/actionwebservice/test/abstract_unit.rb +++ b/actionwebservice/test/abstract_unit.rb @@ -29,3 +29,10 @@ ActiveRecord::Base.establish_connection( ActiveRecord::Base.connection Test::Unit::TestCase.fixture_path = "#{File.dirname(__FILE__)}/fixtures/" + +# restore default raw_post functionality +class ActionController::TestRequest + def raw_post + super + end +end
\ No newline at end of file diff --git a/actionwebservice/test/client_soap_test.rb b/actionwebservice/test/client_soap_test.rb index ee02d919a4..c03c24141f 100644 --- a/actionwebservice/test/client_soap_test.rb +++ b/actionwebservice/test/client_soap_test.rb @@ -142,4 +142,11 @@ class TC_ClientSoap < Test::Unit::TestCase assert_kind_of Accounting::User, scoped_model assert_equal 'Kent', scoped_model.name end + + def test_multi_dim_return + md_struct = @client.multi_dim_return + assert_kind_of Array, md_struct.pref + assert_equal 2, md_struct.pref.size + assert_kind_of Array, md_struct.pref[0] + end end diff --git a/actionwebservice/test/client_xmlrpc_test.rb b/actionwebservice/test/client_xmlrpc_test.rb index 8bb0fdffdc..0abd5898d8 100644 --- a/actionwebservice/test/client_xmlrpc_test.rb +++ b/actionwebservice/test/client_xmlrpc_test.rb @@ -141,4 +141,11 @@ class TC_ClientXmlRpc < Test::Unit::TestCase assert_kind_of Accounting::User, scoped_model assert_equal 'Kent', scoped_model.name end + + def test_multi_dim_return + md_struct = @client.multi_dim_return + assert_kind_of Array, md_struct.pref + assert_equal 2, md_struct.pref.size + assert_kind_of Array, md_struct.pref[0] + end end |