public
Fork of rails/rails
Description: Ruby on Rails - forked for implementing I18n patch
Homepage: http://rubyonrails.org
Clone URL: git://github.com/svenfuchs/rails.git
Fix soap type registration of multidimensional arrays (closes #4232) 
[Kent]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3903 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
dhh (author)
Fri Mar 17 14:20:09 -0800 2006
commit  d4b27a0b36109c6ded5dba57db63d4ff12ec74d1
tree    9676cce672fec31da46a8de358e68c152e44528e
parent  d712310518dcfe42966e7de936794c9a816b0e21
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Fix soap type registration of multidimensional arrays (#4232)
0
+
0
 * Fix that marshaler couldn't handle ActiveRecord models defined in a different namespace (#2392).
0
 
0
 * Fix that marshaler couldn't handle structs with members of ActiveRecord type (#1889).
...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
66
67
68
69
70
71
...
40
41
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
44
45
 
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
 
62
63
64
0
@@ -40,32 +40,25 @@ module ActionWebService
0
         def register_type(type)
0
           return @type2binding[type] if @type2binding.has_key?(type)
0
 
0
- type_class = type.array?? type.element_type.type_class : type.type_class
0
- type_type = type.array?? type.element_type : type
0
- type_binding = nil
0
- if (mapping = @registry.find_mapped_soap_class(type_class) rescue nil)
0
- qname = mapping[2] ? mapping[2][:type] : nil
0
- qname ||= soap_base_type_name(mapping[0])
0
- type_binding = SoapBinding.new(self, qname, type_type, mapping)
0
- else
0
- qname = XSD::QName.new(@namespace, soap_type_name(type_class.name))
0
- @registry.add(type_class,
0
- SOAP::SOAPStruct,
0
- typed_struct_factory(type_class),
0
- { :type => qname })
0
- mapping = @registry.find_mapped_soap_class(type_class)
0
- type_binding = SoapBinding.new(self, qname, type_type, mapping)
0
- end
0
-
0
- array_binding = nil
0
           if type.array?
0
             array_mapping = @registry.find_mapped_soap_class(Array)
0
             qname = XSD::QName.new(@namespace, soap_type_name(type.element_type.type_class.name) + 'Array')
0
- array_binding = SoapBinding.new(self, qname, type, array_mapping, type_binding)
0
+ element_type_binding = register_type(type.element_type)
0
+ @type2binding[type] = SoapBinding.new(self, qname, type, array_mapping, element_type_binding)
0
+ elsif (mapping = @registry.find_mapped_soap_class(type.type_class) rescue nil)
0
+ qname = mapping[2] ? mapping[2][:type] : nil
0
+ qname ||= soap_base_type_name(mapping[0])
0
+ @type2binding[type] = SoapBinding.new(self, qname, type, mapping)
0
+ else
0
+ qname = XSD::QName.new(@namespace, soap_type_name(type.type_class.name))
0
+ @registry.add(type.type_class,
0
+ SOAP::SOAPStruct,
0
+ typed_struct_factory(type.type_class),
0
+ { :type => qname })
0
+ mapping = @registry.find_mapped_soap_class(type.type_class)
0
+ @type2binding[type] = SoapBinding.new(self, qname, type, mapping)
0
           end
0
 
0
- @type2binding[type] = array_binding ? array_binding : type_binding
0
-
0
           if type.structured?
0
             type.each_member do |m_name, m_type|
0
               register_type(m_type)
...
34
35
36
 
 
 
 
37
38
39
...
48
49
50
 
51
52
53
...
124
125
126
 
 
 
 
127
128
129
...
34
35
36
37
38
39
40
41
42
43
...
52
53
54
55
56
57
58
...
129
130
131
132
133
134
135
136
137
138
0
@@ -34,6 +34,10 @@ module ClientTest
0
     member :user, User
0
     member :users, [User]
0
   end
0
+
0
+ class WithMultiDimArray < ActionWebService::Struct
0
+ member :pref, [[:string]]
0
+ end
0
 
0
   class API < ActionWebService::API::Base
0
     api_method :void
0
@@ -48,6 +52,7 @@ module ClientTest
0
     api_method :user_return, :returns => [User]
0
     api_method :with_model_return, :returns => [WithModel]
0
     api_method :scoped_model_return, :returns => [Accounting::User]
0
+ api_method :multi_dim_return, :returns => [WithMultiDimArray]
0
   end
0
   
0
   class NullLogOut
0
@@ -124,6 +129,10 @@ module ClientTest
0
     def scoped_model_return
0
       Accounting::User.find(1)
0
     end
0
+
0
+ def multi_dim_return
0
+ WithMultiDimArray.new :pref => [%w{pref1 value1}, %w{pref2 value2}]
0
+ end
0
   end
0
 
0
   class AbstractClientLet < WEBrick::HTTPServlet::AbstractServlet
...
29
30
31
 
 
 
 
 
 
 
32
...
29
30
31
32
33
34
35
36
37
38
39
0
@@ -29,3 +29,10 @@ ActiveRecord::Base.establish_connection(
0
 ActiveRecord::Base.connection
0
 
0
 Test::Unit::TestCase.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
0
+
0
+# restore default raw_post functionality
0
+class ActionController::TestRequest
0
+ def raw_post
0
+ super
0
+ end
0
+end
0
\ No newline at end of file
...
142
143
144
 
 
 
 
 
 
 
145
...
142
143
144
145
146
147
148
149
150
151
152
0
@@ -142,4 +142,11 @@ class TC_ClientSoap < Test::Unit::TestCase
0
     assert_kind_of Accounting::User, scoped_model
0
     assert_equal 'Kent', scoped_model.name
0
   end
0
+
0
+ def test_multi_dim_return
0
+ md_struct = @client.multi_dim_return
0
+ assert_kind_of Array, md_struct.pref
0
+ assert_equal 2, md_struct.pref.size
0
+ assert_kind_of Array, md_struct.pref[0]
0
+ end
0
 end
...
141
142
143
 
 
 
 
 
 
 
144
...
141
142
143
144
145
146
147
148
149
150
151
0
@@ -141,4 +141,11 @@ class TC_ClientXmlRpc < Test::Unit::TestCase
0
     assert_kind_of Accounting::User, scoped_model
0
     assert_equal 'Kent', scoped_model.name
0
   end
0
+
0
+ def test_multi_dim_return
0
+ md_struct = @client.multi_dim_return
0
+ assert_kind_of Array, md_struct.pref
0
+ assert_equal 2, md_struct.pref.size
0
+ assert_kind_of Array, md_struct.pref[0]
0
+ end
0
 end

Comments

    No one has commented yet.