From 76887202f206ac16dc62d8388fe48164b7588272 Mon Sep 17 00:00:00 2001 From: Marek Veber Date: Tue, 6 Mar 2018 13:14:51 +0100 Subject: [PATCH] add support for group element --- lib/wsdl/soap/classDefCreator.rb | 9 +++++++++ lib/wsdl/soap/mappingRegistryCreatorSupport.rb | 5 +++++ lib/wsdl/xmlSchema/group.rb | 5 +++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/wsdl/soap/classDefCreator.rb b/lib/wsdl/soap/classDefCreator.rb index affaea28b..aaa11d4a2 100644 --- a/lib/wsdl/soap/classDefCreator.rb +++ b/lib/wsdl/soap/classDefCreator.rb @@ -276,6 +276,12 @@ def create_structdef(mpath, qname, typedef, qualified = false) parentmodule = mapped_class_name(qname, mpath) init_lines, init_params = parse_elements(c, typedef.elements, qname.namespace, parentmodule) + if typedef.content && (WSDL::XMLSchema::Group === typedef.content) + g_init_lines, g_init_params = + parse_elements(c, typedef.content.refelement.elements, qname.namespace, parentmodule) + init_lines = (g_init_lines + init_lines) + init_params = (g_init_params + init_params) + end unless typedef.attributes.empty? define_attribute(c, typedef.attributes) init_lines << "@__xmlattr = {}" @@ -337,6 +343,9 @@ def parse_elements(c, elements, base_namespace, mpath, as_array = false) init_lines.concat(child_init_lines) init_params.concat(child_init_params) when WSDL::XMLSchema::Group + if element.ref && element.content.nil? + element.content = element.refelement + end if element.content.nil? warn("no group definition found: #{element}") next diff --git a/lib/wsdl/soap/mappingRegistryCreatorSupport.rb b/lib/wsdl/soap/mappingRegistryCreatorSupport.rb index 1b077f329..e17b72906 100644 --- a/lib/wsdl/soap/mappingRegistryCreatorSupport.rb +++ b/lib/wsdl/soap/mappingRegistryCreatorSupport.rb @@ -62,6 +62,11 @@ def dump_complex_typemap(mpath, qname, typedef, as_element, opt) parentmodule = var[:class] parsed_element = parse_elements(typedef.elements, qname.namespace, parentmodule, opt) + if typedef.content && (WSDL::XMLSchema::Group === typedef.content) && typedef.elements.empty? + g_parsed_element = + parse_elements(typedef.content.refelement.elements, qname.namespace, parentmodule, opt) + parsed_element = (g_parsed_element + parsed_element) + end if typedef.choice? parsed_element.unshift(:choice) end diff --git a/lib/wsdl/xmlSchema/group.rb b/lib/wsdl/xmlSchema/group.rb index f92ca8cb2..57ee65d1c 100644 --- a/lib/wsdl/xmlSchema/group.rb +++ b/lib/wsdl/xmlSchema/group.rb @@ -9,13 +9,14 @@ require 'wsdl/info' require 'wsdl/xmlSchema/ref' +require 'wsdl/xmlSchema/complexType' module WSDL module XMLSchema -class Group < Info +class Group < ComplexType include Ref attr_writer :name # required @@ -89,7 +90,7 @@ def parse_attr(attr, value) end end -private +#private def refelement @refelement ||= (@ref ? root.collect_modelgroups[@ref] : nil)