|
Hi,
first of all, yes, it's a bug, and I even saw it coming - the part where the error crept in already had a #TODO comment.
And I had to add some defensive copying strategy to avoid altering state while passing it down the tree...
Could you try this patch?
Martin
### Eclipse Workspace Patch 1.0
#P SOAP-WSDL-https
Index: lib/SOAP/WSDL/XSD/Typelib/Element.pm
===================================================================
--- lib/SOAP/WSDL/XSD/Typelib/Element.pm (revision 851)
+++ lib/SOAP/WSDL/XSD/Typelib/Element.pm (working copy)
@@ -53,7 +53,9 @@
push @attr_from, q{ xsi:nil="true"};
$ending = '/>';
}
- if (delete $_[1]->{qualified}) {
+ if (defined $_[1]->{ xmlns }) {
+ push @attr_from, qq{ xmlns="$_[1]->{ xmlns }"};
+ } elsif (delete $_[1]->{qualified}) {
push @attr_from, q{ xmlns="} . $_[0]->get_xmlns() . q{"};
}
push @attr_from, $_[0]->serialize_attr();
Index: lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm
===================================================================
--- lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm (revision 851)
+++ lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm (working copy)
@@ -322,7 +322,7 @@
*{ "$class\::_serialize" } = sub {
my $ident = ${ $_[0] };
my $option_ref = $_[1];
-
+
# return concatenated return value of serialize call of all
# elements retrieved from get_elements expanding list refs.
return \join q{} , map {
@@ -337,14 +337,20 @@
my $target_namespace = $_[0]->get_xmlns();
map {
# serialize element elements with their own serializer
- # but name them like they're named here.
- # TODO: check. element ref="" has a name???
if ( $_->isa( 'SOAP::WSDL::XSD::Typelib::Element' ) ) {
# serialize elements of different namespaces
# with namespace declaration
- ($target_namespace ne $_->get_xmlns())
- ? $_->serialize({ name => $name, qualified => 1 })
- : $_->serialize({ name => $name });
+ if (! defined $ELEMENT_FORM_QUALIFIED_OF{ $class }
+ or $ELEMENT_FORM_QUALIFIED_OF{ $class }
+ ) {
+ ($target_namespace ne $_->get_xmlns())
+ ? $_->serialize({ qualified => 1 })
+ : $_->serialize();
+ }
+ else
+ {
+ $_->serialize({ xmlns => "" });
+ }
}
# serialize complextype elments (of other types) with their
# serializer, but add element tags around.
@@ -367,12 +373,12 @@
join q{}, $_->start_tag({ name => $name ,
xmlns => $option_ref->{ xmlns_stack }->[-1],
%{ $option_ref } })
- , $_->serialize($option_ref)
+ , $_->serialize({ %{$option_ref} })
, $_->end_tag({ name => $name , %{ $option_ref } });
}
else {
join q{}, $_->start_tag({ name => $name , %{ $option_ref } })
- , $_->serialize($option_ref)
+ , $_->serialize({ %{$option_ref} })
, $_->end_tag({ name => $name , %{ $option_ref } });
}
}
@@ -386,6 +392,11 @@
# for inner elements
# check whether we "had" a xmlns around
+ # 1. defensively copy
+ # 2. delete from option_ref
+ # Yes, it's ugly to overwrite the variable
+ # let's see if it works...
+ my $option_ref = { %{ $option_ref } };
my $set_xmlns = delete $option_ref->{xmlns};
# serialize start tag with xmlns="" if out parent
@@ -430,11 +441,11 @@
sub __serialize_complex {
# we work on @_ for performance.
$_[1] ||= {}; # $option_ref
-
+
push @{ $_[1]->{ xmlns_stack } }, $_[0]->get_xmlns();
-
+
# get content first (pass by reference to avoid copying)
- my $content_ref = $_[0]->_serialize($_[1]); # option_ref
+ my $content_ref = $_[0]->_serialize({ %{ $_[1]} }); # option_ref
pop @{ $_[1]->{ xmlns_stack } };
|