Skip to content
This repository
Browse code

Fix duplicate XSD entries for custom types (#1729), and prevent recur…

…sive type

traversing.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2014 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 2eba7134455863f936d0b1e8e88284c08ef6b083 1 parent 056838d
Leon Breedt bitserf authored
2  actionwebservice/CHANGELOG
... ... @@ -1,5 +1,7 @@
1 1 *SVN*
2 2
  3 +* Fix duplicate XSD entries for custom types shared across delegated/layered services #1729 [Tyler Kovacs]
  4 +
3 5 * Allow multiple invocations in the same test method #1720 [dkhawk]
4 6
5 7 * Added ActionWebService::API::Base.soap_client and ActionWebService::API::Base.xmlrpc_client helper methods to create the internal clients for an API, useful for testing from ./script/console
21 actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
@@ -195,7 +195,7 @@ def to_wsdl
195 195 custom_types = []
196 196 apis.values.each do |api, bindings|
197 197 bindings.each do |b|
198   - custom_types << b
  198 + custom_types << b unless custom_types.include?(b)
199 199 end
200 200 end
201 201
@@ -347,29 +347,32 @@ def message_name_for(api_name, message_name)
347 347
348 348 def register_api(api, marshaler)
349 349 bindings = {}
350   - traverse_custom_types(api, marshaler) do |binding|
  350 + traverse_custom_types(api, marshaler, bindings) do |binding|
351 351 bindings[binding] = nil unless bindings.has_key?(binding)
352 352 element_binding = binding.element_binding
353   - bindings[binding.element_binding] = nil if element_binding && !bindings.has_key?(element_binding)
  353 + bindings[element_binding] = nil if element_binding && !bindings.has_key?(element_binding)
354 354 end
355 355 bindings.keys
356 356 end
357 357
358   - def traverse_custom_types(api, marshaler, &block)
  358 + def traverse_custom_types(api, marshaler, bindings, &block)
359 359 api.api_methods.each do |name, method|
360 360 expects, returns = method.expects, method.returns
361   - expects.each{ |type| traverse_type(marshaler, type, &block) if type.custom? } if expects
362   - returns.each{ |type| traverse_type(marshaler, type, &block) if type.custom? } if returns
  361 + expects.each{ |type| traverse_type(marshaler, type, bindings, &block) if type.custom? } if expects
  362 + returns.each{ |type| traverse_type(marshaler, type, bindings, &block) if type.custom? } if returns
363 363 end
364 364 end
365 365
366   - def traverse_type(marshaler, type, &block)
367   - yield marshaler.register_type(type)
  366 + def traverse_type(marshaler, type, bindings, &block)
  367 + binding = marshaler.register_type(type)
  368 + return if bindings.has_key?(binding)
  369 + bindings[binding] = nil
  370 + yield binding
368 371 if type.array?
369 372 yield marshaler.register_type(type.element_type)
370 373 type = type.element_type
371 374 end
372   - type.each_member{ |name, type| traverse_type(marshaler, type, &block) } if type.structured?
  375 + type.each_member{ |name, type| traverse_type(marshaler, type, bindings, &block) } if type.structured?
373 376 end
374 377 end
375 378 end

0 comments on commit 2eba713

Please sign in to comment.
Something went wrong with that request. Please try again.