Subject: | [PATCH] handle empty complexTypes correctly |
Date: | Wed, 30 Jan 2008 10:14:11 -0800 |
To: | bug-SOAP-Lite [...] rt.cpan.org |
From: | Jim Radford <radford [...] blackbean.org> |
I get
Can't call method "name" without a package or object reference
when SOAP::Lite is passed a WDSL file with an element containing an
empty complexType and no sequence.
<s:element name="DeletePrompts">
<s:complexType />
</s:element>
The code that parses this relies on "unspecified" perl behavior. I.e.
If the last statement of (a sub) is loop control structure ... then the
return value is unspecified.
For me the following code
perl -MData::Dumper -e 'print Dumper([(sub { if (defined(undef)) { } })->()])'
returns [''] and not [] as one might and SOAP::Lite does expect.
Presumably it returns '' because that is what defined() returns when
it fails.
The following patch removes the reliance on the unspecified behaivor.
-Jim
--- SOAP-Lite-0.69/lib/SOAP/Lite.pm~ 2006-07-06 11:11:44.000000000 -0700
+++ SOAP-Lite-0.69/lib/SOAP/Lite.pm 2008-01-06 14:26:50.000000000 -0800
@@ -2766,13 +2766,13 @@
my $element = shift;
# Current element is a complex type
if (defined($element->complexType)) {
+ my @elements;
if (defined($element->complexType->sequence)) {
- my @elements;
foreach my $e ($element->complexType->sequence->element) {
push @elements,parse_schema_element($e);
}
- return @elements;
}
+ return @elements;
} elsif ($element->simpleType) {
} else {
return $element;