Subject: | [PATCH] Disabling 'die' in Typemaps |
At work I'm working on an application which is supposed to provide a
series of versioned SOAP interfaces. Part of our requirements, is that
it be possible for a 'newer' version of a client to be able to at least
partially be able to talk to and older version of a server. In order
for this to work, SOAP::WSDL need to not die when it encounters an
unexpected element in the SOAP body, and should instead ignore it.
This patch modifies wsdl2perl.pl to add an option called unstrict (u)
which when enabled causes the Typemaps files get_class function to not
die when it is asked for a class it doesn't know what to do with, and
instead return '__SKIP__', which causes the parser to simply skip the block.
Thoughts?
Subject: | unstrict.patch |
Index: lib/SOAP/WSDL/Generator/Template.pm
===================================================================
--- lib/SOAP/WSDL/Generator/Template.pm (revision 764)
+++ lib/SOAP/WSDL/Generator/Template.pm (working copy)
@@ -15,6 +15,7 @@
my %type_prefix_of :ATTR(:name<type_prefix> :default<MyTypes>);
my %element_prefix_of :ATTR(:name<element_prefix> :default<MyElements>);
my %attribute_prefix_of :ATTR(:name<attribute_prefix> :default<MyAttributes>);
+my %unstrict_of :ATTR(:name<unstrict> :default<0>);
my %INCLUDE_PATH_of :ATTR(:name<INCLUDE_PATH> :default<()>);
my %EVAL_PERL_of :ATTR(:name<EVAL_PERL> :default<0>);
my %RECURSION_of :ATTR(:name<RECURSION> :default<0>);
@@ -62,6 +63,7 @@
}),
},
definitions => $self->get_definitions,
+ unstrict => $self->get_unstrict,
NO_POD => delete $arg_ref->{ NO_POD } ? 1 : 0 ,
%{ $arg_ref }
},
Index: lib/SOAP/WSDL/Generator/Template/XSD/Typemap.tt
===================================================================
--- lib/SOAP/WSDL/Generator/Template/XSD/Typemap.tt (revision 764)
+++ lib/SOAP/WSDL/Generator/Template/XSD/Typemap.tt (working copy)
@@ -7,7 +7,13 @@
sub get_class {
my $name = join '/', @{ $_[1] };
- exists $typemap_1->{ $name } or die "Cannot resolve $name via " . __PACKAGE__;
+ exists $typemap_1->{ $name } or
+[%- IF !unstrict -%]
+ die "Cannot resolve $name via " . __PACKAGE__;
+[%- ELSE -%]
+ return '__SKIP__';
+[%- END -%]
+
return $typemap_1->{ $name };
}
Index: bin/wsdl2perl.pl
===================================================================
--- bin/wsdl2perl.pl (revision 764)
+++ bin/wsdl2perl.pl (working copy)
@@ -22,6 +22,7 @@
generator => 'XSD',
server => 0,
namespace => 0,
+ unstrict => 0,
);
{ # a block just to scope "no warnings"
@@ -69,6 +70,7 @@
generator=s
server|s
namespaces|n
+ unstrict|u
)
);
@@ -141,6 +143,8 @@
if $generator->can('set_OUTPUT_PATH');
$generator->set_definitions($definitions)
if $generator->can('set_definitions');
+$generator->set_unstrict($opt{ unstrict })
+ if $generator->can('set_unstrict');
# $generator->set_wsdl($xml) if $generator->can('set_wsdl');
# start with typelib, as errors will most likely occur here...