diff options
Diffstat (limited to 'lib/wsdl/soap/complexType.rb')
-rw-r--r-- | lib/wsdl/soap/complexType.rb | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/lib/wsdl/soap/complexType.rb b/lib/wsdl/soap/complexType.rb index 34fc18f1a4..1bed059f7e 100644 --- a/lib/wsdl/soap/complexType.rb +++ b/lib/wsdl/soap/complexType.rb @@ -7,6 +7,7 @@ require 'wsdl/xmlSchema/complexType' +require 'soap/mapping' module WSDL @@ -20,37 +21,58 @@ class ComplexType < Info def check_type if content - if content.elements.size == 1 and content.elements[0].maxoccurs != 1 - :TYPE_ARRAY + if attributes.empty? and + content.elements.size == 1 and content.elements[0].maxoccurs != '1' + if name == ::SOAP::Mapping::MapQName + :TYPE_MAP + else + :TYPE_ARRAY + end else :TYPE_STRUCT end elsif complexcontent and complexcontent.base == ::SOAP::ValueArrayName :TYPE_ARRAY + elsif simplecontent + :TYPE_SIMPLE + elsif !attributes.empty? + :TYPE_STRUCT else raise NotImplementedError.new("Unknown kind of complexType.") end end def child_type(name = nil) + type = nil case compoundtype when :TYPE_STRUCT if ele = find_element(name) - ele.type + type = ele.type elsif ele = find_element_by_name(name.name) - ele.type - else - nil + type = ele.type end when :TYPE_ARRAY - @contenttype ||= content_arytype + type = @contenttype ||= content_arytype + when :TYPE_MAP + item_ele = find_element_by_name("item") or + raise RuntimeError.new("'item' element not found in Map definition.") + content = item_ele.local_complextype or + raise RuntimeError.new("No complexType definition for 'item'.") + if ele = content.find_element(name) + type = ele.type + elsif ele = content.find_element_by_name(name.name) + type = ele.type + end + else + raise NotImplementedError.new("Unknown kind of complexType.") end + type end def child_defined_complextype(name) ele = nil case compoundtype - when :TYPE_STRUCT + when :TYPE_STRUCT, :TYPE_MAP unless ele = find_element(name) if name.namespace.nil? ele = find_element_by_name(name.name) @@ -81,7 +103,7 @@ class ComplexType < Info return attribute.arytype end end - elsif content.elements.size == 1 and content.elements[0].maxoccurs != 1 + elsif content.elements.size == 1 and content.elements[0].maxoccurs != '1' return content.elements[0].type else raise RuntimeError.new("Assert: Unknown array definition.") |