Subject: | cannot use Complex::Subtype reference as value for Complex::Supertype - Complex::Supertype required |
Hi
I have a hierarchy of types inheriting from SOAP::WSDL::XSD::Typelib::ComplexType, ie:
SOAP::WSDL::XSD::Typelib::ComplexType
IProperty
IAttribute
IAttributeDateTime
IAttributeDouble
IAttributeString
If I use one of the subtypes (eg. IAttributeString) in a constructor that expects one of the supertypes (eg. IAttribute) the constructor fails with something similar to 'cannot
use IAttributeString reference as value for IAttribute - IAttribute required'.
Discovering the hierarchy from the WSDL worked without flaw.
I think that this fixes it for me ( borrowing from your own code a few lines below :-) ):
[SOAP-WSDL]$ svn info
Path: .
URL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap
Repository Root: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl
Repository UUID: 662ab66d-5931-0410-9760-8af722b24055
Revision: 864
Node Kind: directory
Schedule: normal
Last Changed Author: kutterma
Last Changed Rev: 864
Last Changed Date: 2010-06-27 11:08:18 +0200 (Sun, 27 Jun 2010)
[SOAP-WSDL]$ svn diff
Index: lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm
===================================================================
--- lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm (revision 864)
+++ lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm (working copy)
@@ -221,7 +221,7 @@
ref $_
? ref $_ eq 'HASH'
? $type->new($_)
- : ref $_ eq $type
+ : blessed $_ && $_->isa($type)
? $_
: croak "cannot use " . ref($_) . " reference as value for $name - $type required"
: $type->new({ value => $_ })
Thank you for making great (and so much) software.
Tobias