File Coverage

blib/lib/Shipment/SOAP/WSDL.pm
Criterion Covered Total %
statement 140 140 100.0
branch 3 4 75.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 146 147 99.3


line stmt bran cond sub pod time code
1             package Shipment::SOAP::WSDL;
2             $Shipment::SOAP::WSDL::VERSION = '2.00';
3              
4             BEGIN {
5 6     6   29 my %fatpacked;
6              
7 6         23 $fatpacked{"5.10/version.pm"} = <<'5.10_VERSION';
8             #!perl -w
9             package
10             version;
11            
12             use 5.005_04;
13             use strict;
14            
15             use vars qw(@ISA $VERSION $CLASS $STRICT $LAX *declare *qv);
16            
17             $VERSION = 0.82;
18            
19             $CLASS = 'version';
20            
21             #--------------------------------------------------------------------------#
22             # Version regexp components
23             #--------------------------------------------------------------------------#
24            
25             # Fraction part of a decimal version number. This is a common part of
26             # both strict and lax decimal versions
27            
28             my $FRACTION_PART = qr/\.[0-9]+/;
29            
30             # First part of either decimal or dotted-decimal strict version number.
31             # Unsigned integer with no leading zeroes (except for zero itself) to
32             # avoid confusion with octal.
33            
34             my $STRICT_INTEGER_PART = qr/0|[1-9][0-9]*/;
35            
36             # First part of either decimal or dotted-decimal lax version number.
37             # Unsigned integer, but allowing leading zeros. Always interpreted
38             # as decimal. However, some forms of the resulting syntax give odd
39             # results if used as ordinary Perl expressions, due to how perl treats
40             # octals. E.g.
41             # version->new("010" ) == 10
42             # version->new( 010 ) == 8
43             # version->new( 010.2) == 82 # "8" . "2"
44            
45             my $LAX_INTEGER_PART = qr/[0-9]+/;
46            
47             # Second and subsequent part of a strict dotted-decimal version number.
48             # Leading zeroes are permitted, and the number is always decimal.
49             # Limited to three digits to avoid overflow when converting to decimal
50             # form and also avoid problematic style with excessive leading zeroes.
51            
52             my $STRICT_DOTTED_DECIMAL_PART = qr/\.[0-9]{1,3}/;
53            
54             # Second and subsequent part of a lax dotted-decimal version number.
55             # Leading zeroes are permitted, and the number is always decimal. No
56             # limit on the numerical value or number of digits, so there is the
57             # possibility of overflow when converting to decimal form.
58            
59             my $LAX_DOTTED_DECIMAL_PART = qr/\.[0-9]+/;
60            
61             # Alpha suffix part of lax version number syntax. Acts like a
62             # dotted-decimal part.
63            
64             my $LAX_ALPHA_PART = qr/_[0-9]+/;
65            
66             #--------------------------------------------------------------------------#
67             # Strict version regexp definitions
68             #--------------------------------------------------------------------------#
69            
70             # Strict decimal version number.
71            
72             my $STRICT_DECIMAL_VERSION =
73             qr/ $STRICT_INTEGER_PART $FRACTION_PART? /x;
74            
75             # Strict dotted-decimal version number. Must have both leading "v" and
76             # at least three parts, to avoid confusion with decimal syntax.
77            
78             my $STRICT_DOTTED_DECIMAL_VERSION =
79             qr/ v $STRICT_INTEGER_PART $STRICT_DOTTED_DECIMAL_PART{2,} /x;
80            
81             # Complete strict version number syntax -- should generally be used
82             # anchored: qr/ \A $STRICT \z /x
83            
84             $STRICT =
85             qr/ $STRICT_DECIMAL_VERSION | $STRICT_DOTTED_DECIMAL_VERSION /x;
86            
87             #--------------------------------------------------------------------------#
88             # Lax version regexp definitions
89             #--------------------------------------------------------------------------#
90            
91             # Lax decimal version number. Just like the strict one except for
92             # allowing an alpha suffix or allowing a leading or trailing
93             # decimal-point
94            
95             my $LAX_DECIMAL_VERSION =
96             qr/ $LAX_INTEGER_PART (?: \. | $FRACTION_PART $LAX_ALPHA_PART? )?
97             |
98             $FRACTION_PART $LAX_ALPHA_PART?
99             /x;
100            
101             # Lax dotted-decimal version number. Distinguished by having either
102             # leading "v" or at least three non-alpha parts. Alpha part is only
103             # permitted if there are at least two non-alpha parts. Strangely
104             # enough, without the leading "v", Perl takes .1.2 to mean v0.1.2,
105             # so when there is no "v", the leading part is optional
106            
107             my $LAX_DOTTED_DECIMAL_VERSION =
108             qr/
109             v $LAX_INTEGER_PART (?: $LAX_DOTTED_DECIMAL_PART+ $LAX_ALPHA_PART? )?
110             |
111             $LAX_INTEGER_PART? $LAX_DOTTED_DECIMAL_PART{2,} $LAX_ALPHA_PART?
112             /x;
113            
114             # Complete lax version number syntax -- should generally be used
115             # anchored: qr/ \A $LAX \z /x
116             #
117             # The string 'undef' is a special case to make for easier handling
118             # of return values from ExtUtils::MM->parse_version
119            
120             $LAX =
121             qr/ undef | $LAX_DECIMAL_VERSION | $LAX_DOTTED_DECIMAL_VERSION /x;
122            
123             #--------------------------------------------------------------------------#
124            
125             eval "use version::vxs $VERSION";
126             if ( $@ ) { # don't have the XS version installed
127             eval "use version::vpp $VERSION"; # don't tempt fate
128             die "$@" if ( $@ );
129             push @ISA, "version::vpp";
130             local $^W;
131             *version::qv = \&version::vpp::qv;
132             *version::declare = \&version::vpp::declare;
133             *version::_VERSION = \&version::vpp::_VERSION;
134             if ($] > 5.009001 && $] < 5.010000) {
135             no strict 'refs';
136             *version::stringify = \&version::vpp::stringify;
137             *{'version::(""'} = \&version::vpp::stringify;
138             *version::new = \&version::vpp::new;
139             }
140             elsif ($] == 5.010000 || $] == 5.010001) {
141             no strict 'refs';
142             *version::stringify = \&version::vpp::stringify;
143             *{'version::(""'} = \&version::vpp::stringify;
144             *version::new = \&version::vpp::new;
145             *version::parse = \&version::vpp::parse;
146             }
147             }
148             else { # use XS module
149             push @ISA, "version::vxs";
150             local $^W;
151             *version::declare = \&version::vxs::declare;
152             *version::qv = \&version::vxs::qv;
153             *version::_VERSION = \&version::vxs::_VERSION;
154             if ($] > 5.009001 && $] < 5.010000) {
155             no strict 'refs';
156             *version::stringify = \&version::vxs::stringify;
157             *{'version::(""'} = \&version::vxs::stringify;
158             }
159             elsif ($] == 5.010000 || $] == 5.010001) {
160             no strict 'refs';
161             *version::stringify = \&version::vxs::stringify;
162             *{'version::(""'} = \&version::vxs::stringify;
163             *version::new = \&version::vxs::new;
164             *version::parse = \&version::vxs::parse;
165             }
166            
167             }
168            
169             # Preloaded methods go here.
170             sub import {
171             no strict 'refs';
172             my ($class) = shift;
173            
174             # Set up any derived class
175             unless ($class eq 'version') {
176             local $^W;
177             *{$class.'::declare'} = \&version::declare;
178             *{$class.'::qv'} = \&version::qv;
179             }
180            
181             my %args;
182             if (@_) { # any remaining terms are arguments
183             map { $args{$_} = 1 } @_
184             }
185             else { # no parameters at all on use line
186             %args =
187             (
188             qv => 1,
189             'UNIVERSAL::VERSION' => 1,
190             );
191             }
192            
193             my $callpkg = caller();
194            
195             if (exists($args{declare})) {
196             *{$callpkg.'::declare'} =
197             sub {return $class->declare(shift) }
198             unless defined(&{$callpkg.'::declare'});
199             }
200            
201             if (exists($args{qv})) {
202             *{$callpkg.'::qv'} =
203             sub {return $class->qv(shift) }
204             unless defined(&{$callpkg.'::qv'});
205             }
206            
207             if (exists($args{'UNIVERSAL::VERSION'})) {
208             local $^W;
209             *UNIVERSAL::VERSION
210             = \&version::_VERSION;
211             }
212            
213             if (exists($args{'VERSION'})) {
214             *{$callpkg.'::VERSION'} = \&version::_VERSION;
215             }
216            
217             if (exists($args{'is_strict'})) {
218             *{$callpkg.'::is_strict'} =
219             sub {return $class->is_strict(shift)}
220             unless defined(&{$callpkg.'::is_strict'});
221             }
222            
223             if (exists($args{'is_lax'})) {
224             *{$callpkg.'::is_lax'} =
225             sub {return $class->is_lax(shift)}
226             unless defined(&{$callpkg.'::is_lax'});
227             }
228             }
229            
230             sub is_strict { defined $_[0] && $_[0] =~ qr/ \A $STRICT \z /x }
231             sub is_lax { defined $_[0] && $_[0] =~ qr/ \A $LAX \z /x }
232            
233             1;
234             5.10_VERSION
235              
236 6         18 $fatpacked{"5.10/version/vxs.pm"} = <<'5.10_VERSION_VXS';
237             #!perl -w
238             package
239             version::vxs;
240            
241             use 5.005_03;
242             use strict;
243            
244             use vars qw(@ISA $VERSION $CLASS );
245            
246             $VERSION = 0.82;
247            
248             $CLASS = 'version::vxs';
249            
250             eval {
251             require XSLoader;
252             local $^W; # shut up the 'redefined' warning for UNIVERSAL::VERSION
253             XSLoader::load('version::vxs', $VERSION);
254             1;
255             } or do {
256             require DynaLoader;
257             push @ISA, 'DynaLoader';
258             local $^W; # shut up the 'redefined' warning for UNIVERSAL::VERSION
259             bootstrap version::vxs $VERSION;
260             };
261            
262             # Preloaded methods go here.
263            
264             1;
265             5.10_VERSION_VXS
266              
267 6         20 $fatpacked{"SOAP/WSDL.pm"} = <<'SOAP_WSDL';
268             package
269             SOAP::WSDL;
270             use strict;
271             use warnings;
272            
273             use 5.008; # require at least perl 5.8
274            
275             our $Trace = 0;
276             our $Debug = 0;
277            
278             use version; our $VERSION = qv('2.00.99_3');
279            
280             sub import {
281             my $self = shift;
282             for (@_) {
283             $Trace = 9 if $_ eq 'trace';
284             }
285             }
286             1;
287            
288             __END__
289            
290             SOAP_WSDL
291              
292 6         14 $fatpacked{"SOAP/WSDL/Base.pm"} = <<'SOAP_WSDL_BASE';
293             package
294             SOAP::WSDL::Base;
295             use SOAP::WSDL;
296             use strict; use warnings;
297             use Class::Std::Fast::Storable;
298             use List::Util;
299             use Scalar::Util;
300             use Carp qw(croak carp confess);
301            
302             use version; our $VERSION = qv('2.00.99_3');
303            
304             my %id_of :ATTR(:name<id> :default<()>);
305             my %lang_of :ATTR(:name<lang> :default<()>);
306             my %name_of :ATTR(:name<name> :default<()>);
307             my %namespace_of :ATTR(:name<namespace> :default<()>);
308             my %documentation_of :ATTR(:name<documentation> :default<()>);
309             my %annotation_of :ATTR(:name<annotation> :default<()>);
310             my %targetNamespace_of :ATTR(:name<targetNamespace> :default<"">);
311             my %xmlns_of :ATTR(:name<xmlns> :default<{}>);
312             my %parent_of :ATTR(:get<parent> :default<()>);
313            
314             my %namespaces_of :ATTR(:default<{}>);
315            
316             sub namespaces {
317             return shift->get_xmlns();
318             }
319            
320             sub BUILD {
321             my ($self, $ident, $arg_ref) = @_;
322             if (defined $arg_ref->{ parent }) {
323             $parent_of{ $ident } = delete $arg_ref->{ parent },
324             Scalar::Util::weaken($parent_of{ $ident });
325             }
326             }
327            
328             sub START {
329             my ($self, $ident, $arg_ref) = @_;
330             $xmlns_of{ $ident }->{ 'xml' } = 'http://www.w3.org/XML/1998/namespace';
331             $namespaces_of{ $ident }->{ '#default' } = $self->get_xmlns()->{ '#default' };
332             $namespaces_of{ $ident }->{ 'xml' } = 'http://www.w3.org/XML/1998/namespace';
333             }
334            
335             #
336             # set_parent is hand-implemented to break up (weaken) the circular reference
337             # between an object and it's parent
338             #
339             sub set_parent {
340             $parent_of{ ${ $_[0]} } = $_[1];
341             Scalar::Util::weaken($parent_of{ ${ $_[0]} });
342             }
343            
344             # _accept is here to be called by visitor.
345             # The visitor pattern is a level of indirection - here the visitor calls
346             # $object->_accept($visitor) on each object, which in turn calls
347             # $visitor->visit_$class( $object ) where $class is the object's class.
348             #
349             sub _accept {
350             my $self = shift;
351             my $class = ref $self;
352             $class =~ s{ \A SOAP::WSDL:: }{}xms;
353             $class =~ s{ (:? :: ) }{_}gxms;
354             my $method = "visit_$class";
355             no strict qw(refs);
356             return shift->$method( $self );
357             }
358            
359             # unfortunately, AUTOMETHOD is SLOW.
360             # Re-implement in derived package wherever speed is an issue...
361             #
362             sub AUTOMETHOD {
363             my ($self, $ident, @values) = @_;
364             my $subname = $_; # Requested subroutine name is passed via $_
365            
366             # we're called as $self->push_something(@values);
367             if ($subname =~s{^push_}{}xms) {
368             my $getter = "get_$subname";
369             my $setter = "set_$subname";
370             # Checking here is paranoid - will fail fatally if there is no setter.
371             # And we would have to check getters, too.
372             # Maybe do it the Conway way via the Symbol table...
373             # ... can is way slow...
374             return sub {
375             no strict qw(refs);
376             my $old_value = $self->$getter();
377             # Listify if not a list ref
378             $old_value = $old_value ? [ $old_value ] : [] if not ref $old_value;
379            
380             push @$old_value , @values;
381             $self->$setter( $old_value );
382             };
383             }
384            
385             # we're called as $obj->find_something($ns, $key)
386             elsif ($subname =~s {^find_}{get_}xms) {
387             @values = @{ $values[0] } if ref $values[0] eq 'ARRAY';
388             return sub {
389             return List::Util::first {
390             $_->get_targetNamespace() eq $values[0] &&
391             $_->get_name() eq $values[1]
392             }
393             @{ $self->$subname() };
394             }
395             }
396             elsif ($subname =~s {^first_}{get_}xms) {
397             return sub {
398             my $result_ref = $self->$subname();
399             return if not $result_ref;
400             return $result_ref if (not ref $result_ref eq 'ARRAY');
401             return $result_ref->[0];
402             };
403             }
404            
405             return;
406             }
407            
408             sub init {
409             my ($self, @args) = @_;
410             print "Creating new node" . ident($self) . "\n" if $SOAP::WSDL::Trace;
411             foreach my $value (@args) {
412             croak @args if (not defined ($value->{ Name }));
413            
414             print "\tAttribute $value->{ Name } = $value->{ Value }\n" if $SOAP::WSDL::Trace;
415            
416             if ($value->{ Name } =~m{^xmlns\:}xms) {
417             # add namespaces
418             print "\tbind prefix $value->{ LocalName } to $value->{ Value }\n" if $SOAP::WSDL::Trace;
419             $xmlns_of{ ident $self }->{ $value->{ LocalName } } = $value->{ Value };
420             next;
421             }
422            
423             # check for namespae-qualified attributes.
424             # neither XML Schema, nor WSDL1.1, nor the SOAP binding allow
425             # namespace-qualified attribute names
426             my ($ns, $localname) = split /\|/, $value->{ Name };
427             if ($ns) {
428             warn "found unrecognised attribute \{$ns}$localname (ignored)";
429             next;
430             }
431            
432             my $name = $value->{ LocalName };
433             my $method = "set_$name";
434             $self->$method( $value->{ Value } );
435             }
436            
437             return $self;
438             }
439            
440             sub expand {
441             my ($self, $qname) = @_;
442             my $ns_of = $xmlns_of{ ident $self };
443             my $parent;
444             print "Resolving name for $qname in ", $self, " (", ident($self), ")\n" if $SOAP::WSDL::Trace;
445             if (not $qname=~m{:}xm) {
446             if (defined $ns_of->{ '#default' }) {
447             # TODO check. Returning the targetNamespace for the default ns
448             # is probably wrong
449             #return $self->get_targetNamespace(), $qname;
450             return $ns_of->{ '#default' }, $qname;
451             }
452             if ($parent = $self->get_parent()) {
453             return $parent->expand($qname);
454             }
455             die "un-prefixed element name <$qname> found, but no default namespace set\n"
456             }
457            
458             my ($prefix, $localname) = split /:/x, $qname;
459             return ($ns_of->{ $prefix }, $localname) if ($ns_of->{ $prefix });
460             if ($parent = $self->get_parent()) {
461             return $parent->expand($qname);
462             }
463             croak "unbound prefix $prefix found for $prefix:$localname. Bound prefixes are "
464             . join(', ', keys %{ $ns_of });
465             }
466             sub _expand;
467             *_expand = \&expand;
468            
469             sub schema {
470             my $parent = $_[0]->get_parent();
471             return if ! defined $parent;
472             return $parent if $parent->isa('SOAP::WSDL::XSD::Schema');
473             return $parent->schema();
474             }
475            
476             1;
477            
478             __END__
479            
480             # REPOSITORY INFORMATION
481             #
482             # $Rev: 332 $
483             # $LastChangedBy: kutterma $
484             # $Id: WSDL.pm 332 2007-10-19 07:29:03Z kutterma $
485             # $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL.pm $
486             #
487            
488             SOAP_WSDL_BASE
489              
490 6         14 $fatpacked{"SOAP/WSDL/Binding.pm"} = <<'SOAP_WSDL_BINDING';
491             package
492             SOAP::WSDL::Binding;
493             use strict;
494             use warnings;
495             use Class::Std::Fast::Storable;
496            
497             use base qw(SOAP::WSDL::Base);
498            
499             use version; our $VERSION = qv('2.00.99_3');
500            
501             my %operation_of :ATTR(:name<operation> :default<()>);
502             my %type_of :ATTR(:name<type> :default<()>);
503             my %transport_of :ATTR(:name<transport> :default<()>);
504             my %style_of :ATTR(:name<style> :default<()>);
505            
506             1;
507             SOAP_WSDL_BINDING
508              
509 6         18 $fatpacked{"SOAP/WSDL/Build.pm"} = <<'SOAP_WSDL_BUILD';
510             package
511             SOAP::WSDL::Build;
512             {
513             use strict;
514             use warnings;
515             use parent qw(Module::Build);
516            
517             use URI::file;
518             use LWP::UserAgent;
519             use SOAP::WSDL::Expat::WSDLParser;
520             use SOAP::WSDL::Factory::Generator;
521            
522             our $VERSION = 2.01;
523            
524             =pod
525            
526             =head1 NAME
527            
528             SOAP::WSDL::Build - Module::Build subclass for running wsdl2perl during build
529            
530             =head1 SYNOPSIS
531            
532             In your Build.PL:
533            
534             use SOAP::WSDL::Build;
535             my $build = SOAP::WSDL::Build->new(
536             wsdl2perl => {
537             location => 'wsdl/foo.wsdl',
538             prefix => 'SupaModule::',
539             }
540             );
541             $build->generate_build_script();
542            
543             On building/installing:
544            
545             perl Build.PL
546             perl Build
547             perl Build test
548             perl Build install
549            
550             =head1 DESCRIPTION
551            
552             Module::Build subclass for running wsdl2perl during the build stage. This
553             allows shipping of distributions based on SOAP::WSDL, which do not include
554             generated code, but the WSDLs in question instead.
555            
556             =head1 AUTHORING
557            
558             To use SOAP::WSDL::Build in your Build.PL scripts, do the following:
559            
560             =over
561            
562             =item * Use SOAP::WSDL::Build instead of Module::Build
563            
564             use SOAP::WSDL::Build;
565             my $build = SOAP::WSDL::Build->new(%options);
566             $build->generate_build_script();
567            
568             All standard Module::Build methods are still available.
569            
570             =item * Add the wsdl2perl configuration under the options key wsdl2perl:
571            
572             my $build = SOAP::WSDL::Build->new(
573             ...
574             wsdl2perl => {
575             location => 'path/to/wsdl',
576             server => 1,
577             client => 0,
578             prefix => 'My::Project::'
579             }
580             );
581            
582             =back
583            
584             =head2 Options
585            
586             SOAP::WSDL::Builder accepts the following options in the wsdl2perl hash
587             reference:
588            
589             =over
590            
591             =item * Frequently used options
592            
593             =over 8
594            
595             =item * location
596            
597             Path to WSDL file. Required.
598            
599             =item * prefix
600            
601             Prefix to apply to all generated classes.
602            
603             =item * client
604            
605             Generate client interfaces. Defaults to 1 (true)
606            
607             =item * server
608            
609             Generate server interfaces. Defaults to 0 (false)
610            
611             =item * types
612            
613             Generate data classes. Defaults to 1 (true)
614            
615             =item * silent
616            
617             Don't tell what's being generated. Defaults to 0 (false)
618            
619             =back
620            
621             =item * Less frequently used options for the generation process
622            
623             =over 8
624            
625             =item * use_typemap
626            
627             Generate a typemap based parser. This option is only for compatibility with
628             2.00.xx versions and should not be used in any other case. Defaults to 0
629             (false)
630            
631             =item * typemap_include
632            
633             Code snippet to include in typemap. This option is only for compatibility with
634             2.00.xx versions and should not be used in any other case. Defaults to q{}
635             (empty string)
636            
637             =item * attribute_prefix
638            
639             Individual attribute prefix. Defaults to "$prefix\Attributes"
640            
641             =item * interface_prefix
642            
643             Individual (client) interface prefix. Defaults to "$prefix\Interfaces"
644            
645             =item * server_prefix
646            
647             Individual server prefix. Defaults to "$prefix\Server"
648            
649             =item * type_prefix
650            
651             Individual (data) type prefix. Defaults to "$prefix\Types"
652            
653             =item * element_prefix
654            
655             Individual (data) element prefix. Defaults to "$prefix\Elements"
656            
657             =item * typemap_prefix
658            
659             Individual typemap prefix. Defaults to "$prefix\Typemaps"
660            
661             =back
662            
663             =item * Options controlling LWP::UserAgent
664            
665             Use of these options is strongly discouraged for published distributions, as
666             it may make the distribution dependent on your environment
667            
668             =over 8
669            
670             =item * proxy
671            
672             HTTP(s) proxy to use. Proxies can also be set ussing the HTTP_PROXY and
673             HTTPS_PROXY environment variables, which is generally a better choice for build
674             scripts.
675            
676             =item * keepalive
677            
678             Keppalive is only required in combination with NTLM authentication. It is not
679             recommended to create distributions which rely on protected documents, so
680             it's somewhat useless for use in Build scripts.
681            
682             =back
683            
684             =back
685            
686             =head1 Build targets
687            
688             =head2 build
689            
690             SOAP::WSDL::Build modifies the standard "build" target (invoked when running
691             "perl Build") to include the target "webservice".
692            
693             =cut
694            
695             sub ACTION_build {
696             my $self = shift;
697             $self->depends_on('code');
698             $self->depends_on('webservice');
699             $self->depends_on('docs');
700             }
701            
702             =pod
703            
704             =head2 webservice
705            
706             SOAP::WSDL::Build adds the new target webservice. This build target generates
707             perl classes from the WSDL definitions specified.
708            
709             You may run this step separately by calling
710            
711             perl Build webservice
712            
713             =cut
714            
715             sub ACTION_webservice {
716             my $self = shift;
717             $self->read_config();
718             my $config = $self->{properties}->{wsdl2perl};
719             warn "No wsdl2perl config key found in Build.PL ",
720             "- did you forget to add one?\n"
721             if not defined $config;
722             $config = [$config] if ref $config ne 'ARRAY';
723            
724             my %default_config = (
725             base_path => 'blib/lib',
726             generator => 'XSD',
727             silent => 0,
728            
729             client => 1,
730             server => 0,
731             types => 1,
732            
733             keep_alive => 0,
734             proxy => q{},
735            
736             typemap_include => q{},
737             use_typemap => 0,
738            
739             prefix => q{My},
740             attribute_prefix => q{},
741             interface_prefix => q{},
742             server_prefix => q{},
743             type_prefix => q{},
744             element_prefix => q{},
745             typemap_prefix => q{},
746             );
747            
748             foreach my $wsdl_config ( @{$config} ) {
749            
750             # the easiest way to merge two sets is
751             # to just create a new set...
752             $self->wsdl2perl( %default_config, %{$wsdl_config} );
753             }
754             }
755            
756             =pod
757            
758             =head1 METHODS
759            
760             =head2 wsdl2perl
761            
762             $builder->wsdl2perl(%config);
763            
764             =cut
765            
766             sub wsdl2perl {
767             my $self = shift;
768             my %opt = @_;
769            
770             # resolve the default prefix options
771             # If only prefix is given
772             # and interface_prefix has not been set explicitely
773             # make it "$prefix\Interfaces"
774             map {
775             my $opt_key = $_;
776             if (
777             $opt_key =~ / (\w+) _prefix $/xms # relevant option
778             && !$opt{$opt_key} # that hasn't already been explicitly set
779             ) {
780             my $prefix_type = $1;
781             $opt{$opt_key} = $opt{prefix} . # My
782             ucfirst($prefix_type) . # Typemap
783             ( $prefix_type eq 'server' ? '' : 's' ); # s
784             }
785             } keys %opt;
786            
787             # set environment proxies if given
788             # makes sure existing environment proxies are regarded unless
789             # overridden...
790             local $ENV{HTTP_PROXY} = $opt{proxy} if $opt{proxy};
791             local $ENV{HTTPS_PROXY} = $opt{proxy} if $opt{proxy};
792            
793             my $lwp = LWP::UserAgent->new(
794             $opt{keep_alive}
795             ? ( keep_alive => 1 )
796             : () );
797             $lwp->env_proxy()
798             ; # get proxy from environment. Works for both http & https.
799             $lwp->agent(qq[SOAP::WSDL $SOAP::WSDL::Expat::WSDLParser::VERSION]);
800            
801             my $parser =
802             SOAP::WSDL::Expat::WSDLParser->new( {user_agent => $lwp,} );
803            
804             my $uri;
805             if (-e $opt{location}) {
806             $uri = URI::file->new_abs( $opt{location} );
807             }
808             else {
809             warn "wsdl file $opt{location} not found\n"
810             if ($opt{location} !~m{https?://}x);
811             $uri = URI->new($opt{location});
812             }
813            
814            
815             my $definitions = $parser->parse_uri($uri);
816            
817             my %typemap = ();
818             if ( $opt{typemap_include} ) {
819             die "$opt{typemap_include} not found "
820             if not -f $opt{typemap_include};
821             %typemap = do $opt{typemap_include};
822             }
823            
824             my $generator = SOAP::WSDL::Factory::Generator->get_generator(
825             {type => $opt{'generator'}} );
826            
827             if (%typemap) {
828             if ( $generator->can('set_typemap') ) {
829             $generator->set_typemap( \%typemap );
830             }
831             else {
832             warn "Typemap snippet given, but ",
833             "generator does not support it\n";
834             }
835             }
836            
837             $generator->set_attribute_prefix( $opt{attribute_prefix} )
838             if $generator->can('set_attribute_prefix');
839             $generator->set_type_prefix( $opt{type_prefix} )
840             if $generator->can('set_type_prefix');
841             $generator->set_typemap_prefix( $opt{typemap_prefix} )
842             if $generator->can('set_typemap_prefix');
843             $generator->set_element_prefix( $opt{element_prefix} )
844             if $generator->can('set_element_prefix');
845             $generator->set_interface_prefix( $opt{interface_prefix} )
846             if $generator->can('set_interface_prefix');
847             $generator->set_server_prefix( $opt{server_prefix} )
848             if $generator->can('set_server_prefix');
849            
850             $generator->set_OUTPUT_PATH( $opt{base_path} )
851             if $generator->can('set_OUTPUT_PATH');
852             $generator->set_definitions($definitions)
853             if $generator->can('set_definitions');
854            
855             $generator->set_use_typemap( $opt{use_typemap} )
856             if $generator->can('set_use_typemap');
857            
858             $generator->set_silent( $opt{silent} );
859            
860             $generator->generate() if $opt{types};
861             $generator->generate_interface() if $opt{client};
862             $generator->generate_server() if $opt{server};
863             }
864            
865             }
866             1;
867            
868             =pod
869            
870             =head1 EXAMPLE
871            
872             An example is located in the distribution's examples directory in
873            
874             examples/dist
875            
876             =head1 LICENSE AND COPYRIGHT
877            
878             Copyright 2004-2009 Martin Kutter.
879            
880             This file is part of SOAP-WSDL. You may distribute/modify it under the same
881             terms as perl itself
882            
883             =head1 AUTHOR
884            
885             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
886            
887             =head1 REPOSITORY INFORMATION
888            
889             $Rev: 849 $
890             $LastChangedBy: kutterma $
891             $Id: Build.pm 849 2009-05-15 21:39:29Z kutterma $
892             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Build.pm $
893            
894             =cut
895             SOAP_WSDL_BUILD
896              
897 6         19 $fatpacked{"SOAP/WSDL/Client.pm"} = <<'SOAP_WSDL_CLIENT';
898             package
899             SOAP::WSDL::Client;
900             use strict;
901             use warnings;
902             use Carp;
903            
904             use Class::Std::Fast::Storable;
905             use Scalar::Util qw(blessed);
906            
907             use SOAP::WSDL::Factory::Deserializer;
908             use SOAP::WSDL::Factory::Serializer;
909             use SOAP::WSDL::Factory::Transport;
910             use SOAP::WSDL::Expat::MessageParser;
911            
912             use version; our $VERSION = qv('2.00.99_3');
913            
914             my %class_resolver_of :ATTR(:name<class_resolver> :default<()>);
915             my %no_dispatch_of :ATTR(:name<no_dispatch> :default<()>);
916             my %prefix_of :ATTR(:name<prefix> :default<()>);
917             my %outputxml_of :ATTR(:name<outputxml> :default<()>);
918             my %transport_of :ATTR(:name<transport> :default<()>);
919             my %endpoint_of :ATTR(:name<endpoint> :default<()>);
920            
921             my %soap_version_of :ATTR(:get<soap_version> :init_attr<soap_version> :default<1.1>);
922            
923             my %on_action_of :ATTR(:name<on_action> :default<()>);
924             my %content_type_of :ATTR(:name<content_type> :default<text/xml; charset=utf-8>); #/#trick editors
925             my %encoding_of :ATTR(:name<encoding> :default<utf-8>);
926             my %serializer_of :ATTR(:name<serializer> :default<()>);
927             my %deserializer_of :ATTR(:name<deserializer> :default<()>);
928             my %deserializer_args_of :ATTR(:name<deserializer_args> :default<{}>);
929            
930             sub BUILD {
931             my ($self, $ident, $attrs_of_ref) = @_;
932            
933             if (exists $attrs_of_ref->{ proxy }) {
934             $self->set_proxy( $attrs_of_ref->{ proxy } );
935             delete $attrs_of_ref->{ proxy };
936             }
937             return;
938             }
939            
940             sub get_proxy { ## no critic RequireArgUnpacking
941             return $_[0]->get_transport();
942             }
943            
944             sub set_proxy {
945             my ($self, @args_from) = @_;
946             my $ident = ${ $self };
947            
948             # remember old value to return it later - Class::Std does so, too
949             my $old_value = $transport_of{ $ident };
950            
951             # accept both list and list ref args
952             @args_from = @{ $args_from[0] } if ref $args_from[0];
953            
954             # remember endpoint
955             $endpoint_of{ $ident } = $args_from[0];
956            
957             # set transport - SOAP::Lite works similar...
958             $transport_of{ $ident } = SOAP::WSDL::Factory::Transport
959             ->get_transport( @args_from );
960            
961             return $old_value;
962             }
963            
964             sub set_soap_version {
965             my $ident = ${ $_[0] };
966            
967             # remember old value to return it later - Class::Std does so, too
968             my $soap_version = $soap_version_of{ $ident };
969            
970             # re-setting the soap version invalidates the
971             # serializer object
972             delete $serializer_of{ $ident };
973             delete $deserializer_of{ $ident };
974            
975             $soap_version_of{ $ident } = $_[1];
976            
977             return $soap_version;
978             }
979            
980             # Mimic SOAP::Lite's behaviour for getter/setter routines
981             SUBFACTORY: {
982             for (qw(class_resolver no_dispatch outputxml proxy prefix)) {
983             my $setter = "set_$_";
984             my $getter = "get_$_";
985             no strict qw(refs); ## no critic ProhibitNoStrict
986             *{ $_ } = sub { my $self = shift;
987             if (@_) {
988             $self->$setter(@_);
989             return $self;
990             }
991             return $self->$getter()
992             };
993             }
994             }
995            
996             sub call {
997             my ($self, $method, @data_from) = @_;
998             my $ident = ${ $self };
999            
1000             # the only valid idiom for calling a method with both a header and a body
1001             # is
1002             # ->call($method, $body_ref, $header_ref);
1003             #
1004             # These other idioms all assume an empty header:
1005             # ->call($method, %body_of); # %body_of is a hash
1006             # ->call($method, $body); # $body is a scalar
1007             my ($data, $header) = ref $data_from[0]
1008             ? ($data_from[0], $data_from[1] )
1009             : (@data_from>1)
1010             ? ( { @data_from }, undef )
1011             : ( $data_from[0], undef );
1012            
1013             # get operation name and soap_action
1014             my ($operation, $soap_action) = (ref $method eq 'HASH')
1015             ? ( $method->{ operation }, $method->{ soap_action } )
1016             : (blessed $data
1017             && $data->isa('SOAP::WSDL::XSD::Typelib::Builtin::anyType'))
1018             ? ( $method , (join q{/}, $data->get_xmlns(), $method) )
1019             : ( $method, q{} );
1020             $serializer_of{ $ident } ||= SOAP::WSDL::Factory::Serializer->get_serializer({
1021             soap_version => $soap_version_of{ $ident },
1022             });
1023            
1024             my $envelope = $serializer_of{ $ident }->serialize({
1025             method => $operation,
1026             body => $data,
1027             header => $header,
1028             options => {prefix => $prefix_of{ $ident }},
1029             });
1030              
1031             ## output raw request XML
1032             warn "Request\n" . $envelope if $Shipment::SOAP::WSDL::Debug;
1033              
1034             return $envelope if $no_dispatch_of{ $ident };
1035            
1036             # always quote SOAPAction header.
1037             # WS-I BP 1.0 R1109
1038             if ($soap_action) {
1039             $soap_action =~s{\A(:?"|')?}{"}xms;
1040             $soap_action =~s{(:?"|')?\Z}{"}xms;
1041             }
1042             else {
1043             $soap_action = q{""};
1044             }
1045            
1046             # get response via transport layer.
1047             # Normally, SOAP::Lite's transport layer is used, though users
1048             # may provide their own.
1049             my $response = $transport_of{ $ident }->send_receive(
1050             endpoint => $self->get_endpoint(),
1051             content_type => $content_type_of{ $ident },
1052             encoding => $encoding_of{ $ident },
1053             envelope => $envelope,
1054             action => $soap_action,
1055             # on_receive_chunk => sub {} # optional, may be used for parsing large responses as they arrive.
1056             );
1057            
1058             return $response if ($outputxml_of{ $ident } );
1059            
1060             # get deserializer
1061             use Data::Dumper;
1062             $deserializer_of{ $ident } ||= SOAP::WSDL::Factory::Deserializer->get_deserializer({
1063             soap_version => $soap_version_of{ $ident },
1064             %{ $deserializer_args_of{ $ident } },
1065             });
1066            
1067             # initialize deserializer from caller
1068             $deserializer_of{ $ident }->init_from_caller( $self, $method )
1069             if $deserializer_of{ $ident }->can('init_from_caller');
1070            
1071             # Try deserializing response - there may be some,
1072             # even if transport did not succeed (got a 500 response)
1073             if ( $response ) {
1074             # as our faults are false, returning a success marker is the only
1075             # reliable way of determining whether the deserializer succeeded.
1076             # Custom deserializers may return an empty list, or undef,
1077             # and $@ is not guaranteed to be undefined.
1078             my ($success, $result_body, $result_header) = eval {
1079             (1, $deserializer_of{ $ident }->deserialize( $response ));
1080             };
1081             if (defined $success) {
1082             return wantarray
1083             ? ($result_body, $result_header)
1084             : $result_body;
1085             }
1086             elsif (blessed $@) { #}&& $@->isa('SOAP::WSDL::SOAP::Typelib::Fault11')) {
1087             return $@;
1088             }
1089             else {
1090             return $deserializer_of{ $ident }->generate_fault({
1091             code => 'soap:Server',
1092             role => 'urn:localhost',
1093             message => "Error deserializing message: $@. \n"
1094             . "Message was: \n$response"
1095             });
1096             }
1097             };
1098            
1099             # if we had no success (Transport layer error status code)
1100             # or if transport layer failed
1101             if ( ! $transport_of{ $ident }->is_success() ) {
1102            
1103             # generate & return fault if we cannot serialize response
1104             # or have none...
1105             return $deserializer_of{ $ident }->generate_fault({
1106             code => 'soap:Server',
1107             role => 'urn:localhost',
1108             message => 'Error sending / receiving message: '
1109             . $transport_of{ $ident }->message()
1110             });
1111             }
1112             } ## end sub call
1113            
1114             1;
1115            
1116             __END__
1117            
1118             =pod
1119            
1120             =head1 NAME
1121            
1122             SOAP::WSDL::Client - SOAP::WSDL's SOAP Client
1123            
1124             =head1 SYNOPSIS
1125            
1126             use SOAP::WSDL::Client;
1127             my $soap = SOAP::WSDL::Client->new({
1128             proxy => 'http://www.example.org/webservice/test'
1129             });
1130             $soap->call( \%method, $body, $header);
1131            
1132             =head1 METHODS
1133            
1134             =head2 call
1135            
1136             $soap->call( \%method, \@parts );
1137            
1138             %method is a hash with the following keys:
1139            
1140             Name Description
1141             ----------------------------------------------------
1142             operation operation name
1143             soap_action SOAPAction HTTP header to use
1144             style Operation style. One of (document|rpc)
1145             use SOAP body encoding. One of (literal|encoded)
1146            
1147             The style and use keys have no influence yet.
1148            
1149             @parts is a list containing the elements of the message parts.
1150            
1151             For backward compatibility, call may also be called as below:
1152            
1153             $soap->call( $method, \@parts );
1154            
1155             In this case, $method is the SOAP operation name, and the SOAPAction header
1156             is guessed from the first part's namespace and the operation name (which is
1157             mostly correct, but may fail). Operation style and body encoding are assumed to
1158             be document/literal
1159            
1160             =head2 Configuration methods
1161            
1162             =head3 outputxml
1163            
1164             $soap->outputxml(1);
1165            
1166             When set, call() returns the raw XML of the SOAP Envelope.
1167            
1168             =head3 set_content_type
1169            
1170             $soap->set_content_type('application/xml; charset: utf8');
1171            
1172             Sets the content type and character encoding.
1173            
1174             You probably should not use a character encoding different from utf8:
1175             SOAP::WSDL::Client will not convert the request into a different encoding
1176             (yet).
1177            
1178             To leave out the encoding, just set the content type without appending charset
1179             like this:
1180            
1181             $soap->set_content_type('text/xml');
1182            
1183             Default:
1184            
1185             text/xml; charset: utf8
1186            
1187             =head3 set_prefix
1188            
1189             $soap->set_prefix('ns2');
1190            
1191             If set, alters the serialization of the request XML such that the supplied value is used as a namespace prefix for SOAP method calls. By way of example, the default XML serialization returns something like this:
1192            
1193             <?xml version="1.0"?>
1194             <SOAP-ENV:Envelope
1195             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1196             xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
1197             <SOAP-ENV:Body>
1198             <getElementId xmlns="http://services.exmaple.org/">
1199             <elementId>12345</elementId>
1200             </getElementId>
1201             </SOAP-ENV:Body>
1202             </SOAP-ENV:Envelope>
1203            
1204             If the sample set_prefix() call above is used prior to calling your SOAP method, the XML serialization returns this instead:
1205            
1206             <?xml version="1.0"?>
1207             <SOAP-ENV:Envelope
1208             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1209             xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
1210             xmlns:ns2="http://services.example.org/">
1211             <SOAP-ENV:Body>
1212             <ns2:getElementId>
1213             <elementId>12345</elementId>
1214             </ns2:getElementId>
1215             </SOAP-ENV:Body>
1216             </SOAP-ENV:Envelope>
1217            
1218             This is useful in cases where, for instance, one is communicating with a JAX L<https://jax-ws.dev.java.net/> webservice, which tends to understand the latter but not the former. Note that this implementation is currently limited to a single additional namespace; if you require multiple custom namespaces, you should probably look into creating your own serializer.
1219            
1220             =head2 Features different from SOAP::Lite
1221            
1222             SOAP::WSDL does not aim to be a complete replacement for SOAP::Lite - the
1223             SOAP::Lite module has its strengths and weaknesses and SOAP::WSDL is
1224             designed as a cure for the weakness of little WSDL support - nothing more,
1225             nothing less.
1226            
1227             Nonetheless SOAP::WSDL mimics part of SOAP::Lite's API and behaviour,
1228             so SOAP::Lite users can switch without looking up every method call in the
1229             documentation.
1230            
1231             A few things are quite different from SOAP::Lite, though:
1232            
1233             =head3 SOAP request data
1234            
1235             SOAP request data may either be given as message object, or as a hash ref (in
1236             which case it will automatically be encoded into a message object).
1237            
1238             =head3 Return values
1239            
1240             The result from call() is not a SOAP::SOM object, but a message object.
1241            
1242             Message objects' classes may be generated from WSDL definitions automatically
1243             - see SOAP::WSDL::Generator::Typelib on how to generate your own WSDL based
1244             message class library.
1245            
1246             =head3 Fault handling
1247            
1248             SOAP::WSDL::Client returns a fault object on errors, even on transport layer
1249             errors.
1250            
1251             The fault object is a SOAP1.1 fault object of the following
1252             C<SOAP::WSDL::SOAP::Typelib::Fault11>.
1253            
1254             SOAP::WSDL::SOAP::Typelib::Fault11 objects are false in boolean context, so
1255             you can just do something like:
1256            
1257             my $result = $soap->call($method, $data);
1258            
1259             if ($result) {
1260             # handle result
1261             }
1262             else {
1263             die $result->faultstring();
1264             }
1265            
1266             =head3 outputxml
1267            
1268             SOAP::Lite returns only the content of the SOAP body when outputxml is set
1269             to true. SOAP::WSDL::Client returns the complete XML response.
1270            
1271             =head3 Auto-Dispatching
1272            
1273             SOAP::WSDL::Client B<does not> support auto-dispatching.
1274            
1275             This is on purpose: You may easily create interface classes by using
1276             SOAP::WSDL::Client and implementing something like
1277            
1278             sub mySoapMethod {
1279             my $self = shift;
1280             $soap_wsdl_client->call( mySoapMethod, @_);
1281             }
1282            
1283             You may even do this in a class factory - see L<wsdl2perl.pl> for creating
1284             such interfaces.
1285            
1286             =head1 TROUBLESHOOTING
1287            
1288             =head2 Accessing protected web services
1289            
1290             Accessing protected web services is very specific for the transport
1291             backend used.
1292            
1293             In general, you may pass additional arguments to the set_proxy method (or
1294             a list ref of the web service address and any additional arguments to the
1295             new method's I<proxy> argument).
1296            
1297             Refer to the appropriate transport module for documentation.
1298            
1299             =head1 LICENSE AND COPYRIGHT
1300            
1301             Copyright 2004-2007 Martin Kutter.
1302            
1303             This file is part of SOAP-WSDL. You may distribute/modify it under the same
1304             terms as perl itself
1305            
1306             =head1 AUTHOR
1307            
1308             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
1309            
1310             =head1 REPOSITORY INFORMATION
1311            
1312             $Rev: 861 $
1313             $LastChangedBy: kutterma $
1314             $Id: Client.pm 861 2010-03-28 10:41:26Z kutterma $
1315             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Client.pm $
1316            
1317             =cut
1318            
1319             SOAP_WSDL_CLIENT
1320              
1321 6         22 $fatpacked{"SOAP/WSDL/Client/Base.pm"} = <<'SOAP_WSDL_CLIENT_BASE';
1322             package
1323             SOAP::WSDL::Client::Base;
1324             use strict;
1325             use warnings;
1326             use base 'SOAP::WSDL::Client';
1327             use Scalar::Util qw(blessed);
1328            
1329             use version; our $VERSION = qv('2.00.99_3');
1330            
1331             sub call {
1332             my ($self, $method, $body, $header) = @_;
1333            
1334             # Treat non-objects special
1335             if (not blessed $body) {
1336            
1337             # make sure there's something sensible in our body data
1338             $body = {} if not defined $body;
1339             $body = ref $body eq 'ARRAY' ? $body : [ $body ];
1340            
1341             my @body_from = @{ $body }; # make a copy
1342            
1343             # build list of parts as objects initialized with
1344             # parameters given
1345             my @part_from = ();
1346             foreach my $class (@{ $method->{ body }->{ parts } }) {
1347             eval "require $class" || die $@; ## no critic (ProhibitStringyEval)
1348             push @part_from, $class->new(shift(@body_from) || {});
1349             }
1350            
1351             # it's either the first part or a list ref with all parts...
1352             $body = $#part_from ? \@part_from : $part_from[0];
1353             }
1354            
1355             # if we have a header
1356             if (%{ $method->{ header } }) {
1357            
1358             # treat non object special - as above, but only for one
1359             if (not blessed $header) {
1360             my $class = $method->{ header }->{ parts }->[0];
1361             eval "require $class" || die $@; ## no critic (ProhibitStringyEval)
1362             $header = $class->new($header);
1363             }
1364             }
1365             return $self->SUPER::call($method, $body, $header);
1366             }
1367            
1368             1;
1369            
1370             __END__
1371            
1372             SOAP_WSDL_CLIENT_BASE
1373              
1374 6         1215 $fatpacked{"SOAP/WSDL/Definitions.pm"} = <<'SOAP_WSDL_DEFINITIONS';
1375             package
1376             SOAP::WSDL::Definitions;
1377             use strict;
1378             use warnings;
1379             use List::Util qw(first);
1380             use Class::Std::Fast::Storable;
1381             use base qw(SOAP::WSDL::Base);
1382            
1383             use version; our $VERSION = qv('2.00.99_3');
1384            
1385             my %types_of :ATTR(:name<types> :default<[]>);
1386             my %message_of :ATTR(:name<message> :default<[]>);
1387             my %portType_of :ATTR(:name<portType> :default<[]>);
1388             my %binding_of :ATTR(:name<binding> :default<[]>);
1389             my %service_of :ATTR(:name<service> :default<[]>);
1390             my %namespace_of :ATTR(:name<namespace> :default<()>);
1391            
1392             # must be attr for Class::Std::Fast::Storable
1393             #my %attributes_of :ATTR();
1394             my %attributes_of = (
1395             binding => \%binding_of,
1396             message => \%message_of,
1397             portType => \%portType_of,
1398             service => \%service_of,
1399             );
1400            
1401             # Function factory - we could be writing this method for all %attribute
1402             # keys, too, but that's just C&P (eehm, Copy & Paste...)
1403             BLOCK: {
1404             foreach my $method(keys %attributes_of ) {
1405             no strict qw/refs/; ## no critic ProhibitNoStrict
1406             *{ "find_$method" } = sub {
1407             my ($self, @args_from) = @_;
1408             @args_from = @{ $args_from[0] } if ref $args_from[0] eq 'ARRAY';
1409             return first {
1410             $_->get_targetNamespace() eq $args_from[0]
1411             && $_->get_name() eq $args_from[1]
1412             }
1413             @{ $attributes_of{ $method }->{ ident $self } };
1414             };
1415             }
1416             }
1417            
1418            
1419             1;
1420            
1421             =pod
1422            
1423             =head1 NAME
1424            
1425             SOAP::WSDL::Definitions - model a WSDL E<gt>definitionsE<lt> element
1426            
1427             =head1 DESCRIPTION
1428            
1429             =head1 METHODS
1430            
1431             =head2 first_service get_service set_service push_service
1432            
1433             Accessors/Mutators for accessing / setting the E<gt>serviceE<lt> child
1434             element(s).
1435            
1436             =head2 find_service
1437            
1438             Returns the service matching the namespace/localname pair passed as arguments.
1439            
1440             my $service = $wsdl->find_service($namespace, $localname);
1441            
1442             =head2 first_binding get_binding set_binding push_binding
1443            
1444             Accessors/Mutators for accessing / setting the E<gt>bindingE<lt> child
1445             element(s).
1446            
1447             =head2 find_binding
1448            
1449             Returns the binding matching the namespace/localname pair passed as arguments.
1450            
1451             my $binding = $wsdl->find_binding($namespace, $localname);
1452            
1453             =head2 first_portType get_portType set_portType push_portType
1454            
1455             Accessors/Mutators for accessing / setting the E<gt>portTypeE<lt> child
1456             element(s).
1457            
1458             =head2 find_portType
1459            
1460             Returns the portType matching the namespace/localname pair passed as arguments.
1461            
1462             my $portType = $wsdl->find_portType($namespace, $localname);
1463            
1464             =head2 first_message get_message set_message push_message
1465            
1466             Accessors/Mutators for accessing / setting the E<gt>messageE<lt> child
1467             element(s).
1468            
1469             =head2 find_message
1470            
1471             Returns the message matching the namespace/localname pair passed as arguments.
1472            
1473             my $message = $wsdl->find_message($namespace, $localname);
1474            
1475             =head2 first_types get_types set_types push_types
1476            
1477             Accessors/Mutators for accessing / setting the E<gt>typesE<lt> child
1478             element(s).
1479            
1480             =head1 LICENSE AND COPYRIGHT
1481            
1482             Copyright 2004-2007 Martin Kutter.
1483            
1484             This file is part of SOAP-WSDL. You may distribute/modify it under
1485             the same terms as perl itself
1486            
1487             =head1 AUTHOR
1488            
1489             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
1490            
1491             =head1 REPOSITORY INFORMATION
1492            
1493             $Rev: 861 $
1494             $LastChangedBy: kutterma $
1495             $Id: Definitions.pm 861 2010-03-28 10:41:26Z kutterma $
1496             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Definitions.pm $
1497            
1498             =cut
1499            
1500             SOAP_WSDL_DEFINITIONS
1501              
1502 6         21 $fatpacked{"SOAP/WSDL/Deserializer/Hash.pm"} =
1503             <<'SOAP_WSDL_DESERIALIZER_HASH';
1504             package
1505             SOAP::WSDL::Deserializer::Hash;
1506             use strict;
1507             use warnings;
1508             use Class::Std::Fast::Storable;
1509             use SOAP::WSDL::SOAP::Typelib::Fault11;
1510             use SOAP::WSDL::Expat::Message2Hash;
1511            
1512             use SOAP::WSDL::Factory::Deserializer;
1513             SOAP::WSDL::Factory::Deserializer->register( '1.1', __PACKAGE__ );
1514            
1515             use version; our $VERSION = qv('2.00.99_3');
1516            
1517             sub BUILD {
1518             my ($self, $ident, $args_of_ref) = @_;
1519            
1520             # ignore all options
1521             for (keys %{ $args_of_ref }) {
1522             delete $args_of_ref->{ $_ }
1523             }
1524             }
1525            
1526             sub deserialize {
1527             my ($self, $content) = @_;
1528            
1529             my $parser = SOAP::WSDL::Expat::Message2Hash->new();
1530             eval { $parser->parse_string( $content ) };
1531             if ($@) {
1532             die $self->generate_fault({
1533             code => 'soap:Server',
1534             role => 'urn:localhost',
1535             message => "Error deserializing message: $@. \n"
1536             . "Message was: \n$content"
1537             });
1538             }
1539             return $parser->get_data();
1540             }
1541            
1542             sub generate_fault {
1543             my ($self, $args_from_ref) = @_;
1544             return SOAP::WSDL::SOAP::Typelib::Fault11->new({
1545             faultcode => $args_from_ref->{ code } || 'SOAP-ENV:Client',
1546             faultactor => $args_from_ref->{ role } || 'urn:localhost',
1547             faultstring => $args_from_ref->{ message } || "Unknown error"
1548             });
1549             }
1550            
1551             1;
1552            
1553             =head1 NAME
1554            
1555             SOAP::WSDL::Deserializer::Hash - Deserializer SOAP messages into perl hash refs
1556            
1557             =head1 SYNOPSIS
1558            
1559             use SOAP::WSDL;
1560             use SOAP::WSDL::Deserializer::Hash;
1561            
1562             =head1 DESCRIPTION
1563            
1564             Deserializer for creating perl hash refs as result of a SOAP call.
1565            
1566             =head2 Output structure
1567            
1568             The XML structure is converted into a perl data structure consisting of
1569             hash and or list references. List references are used for holding array data.
1570            
1571             SOAP::WSDL::Deserializer::Hash creates list references always at the maximum
1572             depth possible.
1573            
1574             Examples:
1575            
1576             XML:
1577             <MyDataArray>
1578             <MyData>1</MyData>
1579             <MyData>1</MyData>
1580             </MyDataArray>
1581            
1582             Perl:
1583             {
1584             MyDataArray => {
1585             MyData => [ 1, 1 ]
1586             }
1587             }
1588            
1589             XML:
1590             <DeepArray>
1591             <MyData><int>1<int>/MyData>
1592             <MyData><int>1<int>/MyData>
1593             </DeepArray>
1594            
1595             Perl:
1596             {
1597             MyDataArray => {
1598             MyData => [
1599             { int => 1 },
1600             { int => 1 }
1601             ]
1602             }
1603             }
1604            
1605             List reference creation is triggered by the second occurance of an element.
1606             XML Array types with one element only will not be represented as list
1607             references.
1608            
1609             =head1 USAGE
1610            
1611             All you need to do is to use SOAP::WSDL::Deserializer::Hash.
1612            
1613             SOAP::WSDL::Deserializer::Hash autoregisters itself for SOAP1.1 messages
1614            
1615             You may register SOAP::WSDLDeserializer::Hash for other SOAP Versions by
1616             calling
1617            
1618             SOAP::Factory::Deserializer->register('1.2',
1619             SOAP::WSDL::Deserializer::Hash)
1620            
1621             =head1 Limitations
1622            
1623             =over
1624            
1625             =item * Namespaces
1626            
1627             All namespaces are ignored.
1628            
1629             =item * XML attributes
1630            
1631             All XML attributes are ignored.
1632            
1633             =back
1634            
1635             =head2 Differences from other SOAP::WSDL::Deserializer classes
1636            
1637             =over
1638            
1639             =item * generate_fault
1640            
1641             SOAP::WSDL::Deserializer::Hash will die with a SOAP::WSDL::Fault11 object when
1642             a parse error appears
1643            
1644             =back
1645            
1646             =head1 METHODS
1647            
1648             =head2 deserialize
1649            
1650             Deserializes the message.
1651            
1652             =head2 generate_fault
1653            
1654             Generates a L<SOAP::WSDL::SOAP::Typelib::Fault11|SOAP::WSDL::SOAP::Typelib::Fault11>
1655             object and returns it.
1656            
1657             =head1 LICENSE AND COPYRIGHT
1658            
1659             Copyright 2004-2008 Martin Kutter.
1660            
1661             This file is part of SOAP-WSDL. You may distribute/modify it under
1662             the same terms as perl itself.
1663            
1664             =head1 AUTHOR
1665            
1666             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
1667            
1668             =head1 REPOSITORY INFORMATION
1669            
1670             $Rev: 861 $
1671             $LastChangedBy: kutterma $
1672             $Id: Hash.pm 861 2010-03-28 10:41:26Z kutterma $
1673             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Deserializer/Hash.pm $
1674            
1675             =cut
1676             SOAP_WSDL_DESERIALIZER_HASH
1677              
1678 6         16 $fatpacked{"SOAP/WSDL/Deserializer/SOM.pm"} =
1679             <<'SOAP_WSDL_DESERIALIZER_SOM';
1680             package
1681             SOAP::WSDL::Deserializer::SOM;
1682             use strict;
1683             use warnings;
1684            
1685             use version; our $VERSION = qv('2.00.99_3');
1686             our @ISA;
1687            
1688             eval {
1689             require SOAP::Lite;
1690             push @ISA, 'SOAP::Deserializer';
1691             }
1692             or die "Cannot load SOAP::Lite.
1693             Cannot deserialize to SOM object without SOAP::Lite.
1694             Please install SOAP::Lite.";
1695            
1696             sub deserialize {
1697             my $self = shift;
1698             my $result = eval { $self->SUPER::deserialize(@_) };
1699             if ($@) {
1700             return SOAP::Fault->new(
1701             faultactor => 'SOAP-ENV:Server',
1702             faultstring => $@,
1703             );
1704             }
1705             return $result;
1706             }
1707            
1708             sub generate_fault {
1709             my ($self, $args_from_ref) = @_;
1710             # code, message, detail, actor
1711             die SOAP::Fault->new(
1712             faultcode => $args_from_ref->{ code },
1713             faultstring => $args_from_ref->{ message },
1714             faultactor => $args_from_ref->{ role },
1715             );
1716             }
1717            
1718             1;
1719            
1720             __END__
1721            
1722             =head1 NAME
1723            
1724             SOAP::WSDL::Deserializer::SOM - Deserializer SOAP messages into SOM objects
1725            
1726             =head1 SYNOPSIS
1727            
1728             use SOAP::WSDL;
1729             use SOAP::WSDL::Deserializer::SOM;
1730             use SOAP::WSDL::Factory::Deserializer;
1731             SOAP::WSDL::Factory::Deserializer->register( '1.1', __PACKAGE__ );
1732            
1733             =head1 DESCRIPTION
1734            
1735             Deserializer for creating SOAP::Lite's SOM object as result of a SOAP call.
1736            
1737             This package is here for two reasons:
1738            
1739             =over
1740            
1741             =item * Compatibility
1742            
1743             You don't have to change the rest of your SOAP::Lite based app when switching
1744             to SOAP::WSDL, but can just use SOAP::WSDL::Deserializer::SOM to get back the
1745             same objects as you were used to.
1746            
1747             =item * Completeness
1748            
1749             SOAP::Lite covers much more of the SOAP specification than SOAP::WSDL.
1750            
1751             SOAP::WSDL::Deserializer::SOM can be used for content which cannot be
1752             deserialized by L<SOAP::WSDL::Deserializer::SOAP11|SOAP::WSDL::Deserializer::SOAP11>.
1753             This may be XML including mixed content, attachements and other XML data not
1754             (yet) handled by L<SOAP::WSDL::Deserializer::SOAP11|SOAP::WSDL::Deserializer::SOAP11>.
1755            
1756             =back
1757            
1758             SOAP::WSDL::Deserializer::SOM is a subclass of L<SOAP::Deserializer|SOAP::Deserializer>
1759             from the L<SOAP::Lite|SOAP::Lite> package.
1760            
1761             =head1 METHODS
1762            
1763             =head2 deserialize
1764            
1765             Deserializes a XML sting into a SOAP::SOM object. Returns a SOAP::Fault object
1766             on deserialization errors.
1767            
1768             =head2 generate_fault
1769            
1770             Dies with a SOAP::Fault object.
1771            
1772             =head1 USAGE
1773            
1774             SOAP::WSDL::Deserializer will not autoregister itself - to use it for a particular
1775             SOAP version just use the following lines:
1776            
1777             my $soap_version = '1.1'; # or '1.2', further versions may appear.
1778            
1779             use SOAP::WSDL::Deserializer::SOM;
1780             use SOAP::WSDL::Factory::Deserializer;
1781             SOAP::WSDL::Factory::Deserializer->register( $soap_version, __PACKAGE__ );
1782            
1783             =head1 DIFFERENCES FROM OTHER CLASSES
1784            
1785             =head2 Differences from SOAP::Lite
1786            
1787             =over
1788            
1789             =item * No on_fault handler
1790            
1791             You cannot specify what to do when an error occurs - SOAP::WSDL will return
1792             a SOAP::Fault object on transport errors.
1793            
1794             =back
1795            
1796             =head2 Differences from other SOAP::WSDL::Deserializer classes
1797            
1798             =over
1799            
1800             =item * generate_fault
1801            
1802             SOAP::WSDL::Deserializer::SOM will die with a SOAP::Fault object on calls
1803             to generate_fault.
1804            
1805             This also means that a SOAP::Fault may be thrown as exception when using
1806            
1807            
1808             =back
1809            
1810             =head1 LICENSE AND COPYRIGHT
1811            
1812             Copyright 2004-2007 Martin Kutter.
1813            
1814             This file is part of SOAP-WSDL. You may distribute/modify it under
1815             the same terms as perl itself.
1816            
1817             =head1 AUTHOR
1818            
1819             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
1820            
1821             =head1 REPOSITORY INFORMATION
1822            
1823             $Rev: 861 $
1824             $LastChangedBy: kutterma $
1825             $Id: SOM.pm 861 2010-03-28 10:41:26Z kutterma $
1826             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Deserializer/SOM.pm $
1827            
1828             =cut
1829             SOAP_WSDL_DESERIALIZER_SOM
1830              
1831 6         19 $fatpacked{"SOAP/WSDL/Deserializer/XSD.pm"} =
1832             <<'SOAP_WSDL_DESERIALIZER_XSD';
1833             package
1834             SOAP::WSDL::Deserializer::XSD;
1835             use strict;
1836             use warnings;
1837             use Class::Std::Fast::Storable;
1838             use SOAP::WSDL::SOAP::Typelib::Fault11;
1839             use SOAP::WSDL::Expat::MessageParser;
1840            
1841             use version; our $VERSION = qv('2.00.99_3');
1842            
1843             my %class_resolver_of :ATTR(:name<class_resolver> :default<()>);
1844             my %response_header_parts_of :ATTR(:name<response_header_parts> :default<()>);
1845             my %response_body_parts_of :ATTR(:name<response_body_parts> :default<()>);
1846             my %strict_of :ATTR(:get<strict> :init_arg<strict> :default<1>);
1847             my %parser_of :ATTR();
1848            
1849             sub set_strict {
1850             undef $parser_of{${$_[0]}};
1851             $strict_of{${$_[0]}} = $_[1];
1852             }
1853            
1854             # TODO cleanup
1855             #
1856             # init_from_caller is currently in a pretty ugly state, due to a late
1857             # introduction os some kind of inversion of control.
1858             #
1859             # init_from_caller transfers control over the initialization process from
1860             # the SOAP::WSDL::Client to the deserializer, which can grab the information
1861             # required from the (passed) calling object.
1862             #
1863             # The inversion of control is currently incomplete, because the deserializer
1864             # cannot get the method info from the client (this is not implemented yet)
1865             # and therefor gets passed the method info hash ref.
1866             #
1867             # Moreover, method names for retrieving class and name resolver are
1868             # somewhat mixed up.
1869             #
1870             # Unfortunately, we cannot just change the implementataion, as it would
1871             # require users to re-generate their interfaces.
1872            
1873             sub init_from_caller {
1874             my ($self, $caller, $method) = @_;
1875            
1876             my $parser
1877             = $parser_of{ ${ $self } }
1878             ||= SOAP::WSDL::Expat::MessageParser->new();
1879            
1880             # old style
1881             $parser->class_resolver( $caller->get_class_resolver() )
1882             if $caller->can('get_class_resolver');
1883            
1884             # new style
1885             $parser->set_name_resolver( $caller->_get_name_resolver() )
1886             if $caller->can('get_name_resolver');
1887            
1888             if ( ref $method ) {
1889             # set class resolver if serializer supports it
1890             if ( $caller->isa('SOAP::WSDL::Client') ) {
1891             $parser->set_header_parts( $method->{header}->{response}->{parts} );
1892             $parser->set_body_parts( $method->{body}->{response}->{parts} );
1893             }
1894             else {
1895             $parser->set_header_parts( $method->{header}->{parts} );
1896             $parser->set_body_parts( $method->{body}->{parts} );
1897             }
1898             }
1899             }
1900            
1901             sub deserialize {
1902             my ($self, $content) = @_;
1903            
1904             $parser_of{ ${ $self } } = SOAP::WSDL::Expat::MessageParser->new({
1905             strict => $strict_of{ ${ $self } },
1906             # old style init variant
1907             (defined $class_resolver_of{${ $self }}
1908             ? (class_resolver => $class_resolver_of{${ $self }})
1909             : () )
1910             })
1911             if not $parser_of{ ${ $self } };
1912            
1913             eval { $parser_of{ ${ $self } }->parse_string( $content ) };
1914             if ($@) {
1915             return $self->generate_fault({
1916             code => 'SOAP-ENV:Server',
1917             role => 'urn:localhost',
1918             message => "Error deserializing message: $@. \n"
1919             . "Message was: \n$content"
1920             });
1921             }
1922             return ( $parser_of{ ${ $self } }->get_data(), $parser_of{ ${ $self } }->get_header() );
1923             }
1924            
1925             sub generate_fault {
1926             my ($self, $args_from_ref) = @_;
1927             return SOAP::WSDL::SOAP::Typelib::Fault11->new({
1928             faultcode => $args_from_ref->{ code } || 'SOAP-ENV:Client',
1929             faultactor => $args_from_ref->{ role } || 'urn:localhost',
1930             faultstring => $args_from_ref->{ message } || "Unknown error"
1931             });
1932             }
1933            
1934             1;
1935            
1936             __END__
1937            
1938             =head1 NAME
1939            
1940             SOAP::WSDL::Deserializer::XSD - Deserializer SOAP messages into SOAP::WSDL::XSD::Typelib:: objects
1941            
1942             =head1 DESCRIPTION
1943            
1944             Default deserializer for SOAP::WSDL::Client and interface classes generated by
1945             SOAP::WSDL. Converts SOAP messages to SOAP::WSDL::XSD::Typlib:: based objects.
1946            
1947             Needs a class_resolver typemap either passed by the generated interface
1948             or user-provided.
1949            
1950             SOAP::WSDL::Deserializer classes implement the API described in
1951             L<SOAP::WSDL::Factory::Deserializer>.
1952            
1953             =head1 USAGE
1954            
1955             Usually you don't need to do anything to use this package - it's the default
1956             deserializer for SOAP::WSDL::Client and interface classes generated by
1957             SOAP::WSDL.
1958            
1959             If you want to use the XSD serializer from SOAP::WSDL, set the outputtree()
1960             property and provide a class_resolver.
1961            
1962             =head1 OPTIONS
1963            
1964             =over
1965            
1966             =item * strict
1967            
1968             Enables/disables strict XML processing. Strict processing is enabled by
1969             default. To disable strict XML processing pass the following to the
1970             constructor or use the C<set_strict> method:
1971            
1972             strict => 0
1973            
1974             =back
1975            
1976             =head1 METHODS
1977            
1978             =head2 deserialize
1979            
1980             Deserializes the message.
1981            
1982             =head2 generate_fault
1983            
1984             Generates a L<SOAP::WSDL::SOAP::Typelib::Fault11|SOAP::WSDL::SOAP::Typelib::Fault11>
1985             object and returns it.
1986            
1987             =head2 set_strict
1988            
1989             Enable/disable strict XML parsing. Default is enabled.
1990            
1991             =head1 LICENSE AND COPYRIGHT
1992            
1993             Copyright 2004-2007 Martin Kutter.
1994            
1995             This file is part of SOAP-WSDL. You may distribute/modify it under
1996             the same terms as perl itself.
1997            
1998             =head1 AUTHOR
1999            
2000             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
2001            
2002             =head1 REPOSITORY INFORMATION
2003            
2004             $Rev: 861 $
2005             $LastChangedBy: kutterma $
2006             $Id: XSD.pm 861 2010-03-28 10:41:26Z kutterma $
2007             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Deserializer/XSD.pm $
2008            
2009             =cut
2010             SOAP_WSDL_DESERIALIZER_XSD
2011              
2012 6         17 $fatpacked{"SOAP/WSDL/Expat/Base.pm"} = <<'SOAP_WSDL_EXPAT_BASE';
2013             package
2014             SOAP::WSDL::Expat::Base;
2015             use strict;
2016             use warnings;
2017             use URI;
2018             use XML::Parser::Expat;
2019            
2020             # TODO: convert to Class::Std::Fast based class - hash based classes suck.
2021            
2022             use version; our $VERSION = qv('2.00.99_3');
2023            
2024             sub new {
2025             my ($class, $arg_ref) = @_;
2026             my $self = {
2027             data => undef,
2028             };
2029             bless $self, $class;
2030            
2031             $self->set_user_agent($arg_ref->{ user_agent })
2032             if $arg_ref->{ user_agent };
2033             $self->{ parsed } = $arg_ref->{ parsed } if $arg_ref->{ parsed };
2034            
2035             return $self;
2036             }
2037            
2038             sub clone {
2039             my $self = shift;
2040             my $class = ref $self;
2041             my $clone = $class->new($self);
2042             return $clone;
2043             }
2044            
2045             sub set_uri { $_[0]->{ uri } = $_[1]; }
2046             sub get_uri { return $_[0]->{ uri }; }
2047            
2048             sub set_user_agent { $_[0]->{ user_agent } = $_[1]; }
2049             sub get_user_agent { return $_[0]->{ user_agent }; }
2050            
2051             # Mark a URI as "already parsed"
2052             sub set_parsed {
2053             my ($self, $uri) = @_;
2054             $self->{ parsed }->{ $uri } = 1;
2055             return;
2056             }
2057            
2058            
2059             # returns true if a specific URI has already been parsed
2060             sub is_parsed {
2061             my ($self, $uri) = @_;
2062             return exists $self->{ parsed }->{ $uri };
2063             }
2064            
2065            
2066             # parse a URI. This is the preferred parsing method for WSDL files, as it's
2067             # the only one allowing automatic import resolution
2068             sub parse_uri {
2069             my $self = shift;
2070             my $uri = shift;
2071            
2072             if ($self->is_parsed($uri)){
2073             warn "$uri already imported; ignoring it.\n";
2074             return;
2075             }
2076             $self->set_parsed($uri);
2077            
2078             $self->set_uri( $uri );
2079            
2080             if (not $self->{ user_agent }) {
2081             require LWP::UserAgent;
2082             $self->{ user_agent } = LWP::UserAgent->new();
2083             }
2084            
2085             my $response = $self->{ user_agent }->get($uri);
2086             die $response->message() if $response->code() ne '200';
2087             return $self->parse( $response->content() );
2088             }
2089            
2090             sub parse {
2091             eval {
2092             $_[0]->_initialize( XML::Parser::Expat->new( Namespaces => 1 ) )->parse( $_[1] );
2093             $_[0]->{ parser }->release();
2094             };
2095             $_[0]->{ parser }->xpcroak( $@ ) if $@;
2096             delete $_[0]->{ parser };
2097             return $_[0]->{ data };
2098             }
2099            
2100             sub parsefile {
2101             eval {
2102             $_[0]->_initialize( XML::Parser::Expat->new(Namespaces => 1) )->parsefile( $_[1] );
2103             $_[0]->{ parser }->release();
2104             };
2105             $_[0]->{ parser }->xpcroak( $@ ) if $@;
2106             delete $_[0]->{ parser };
2107             return $_[0]->{ data };
2108             }
2109            
2110             # SAX-like aliases
2111             sub parse_string;
2112             *parse_string = \&parse;
2113            
2114             sub parse_file;
2115             *parse_file = \&parsefile;
2116            
2117             sub get_data {
2118             return $_[0]->{ data };
2119             }
2120            
2121             1;
2122            
2123             =pod
2124            
2125             =head1 NAME
2126            
2127             SOAP::WSDL::Expat::Base - Base class for XML::Parser::Expat based XML parsers
2128            
2129             =head1 DESCRIPTION
2130            
2131             Base class for XML::Parser::Expat based XML parsers. All XML::SAX::Expat based
2132             parsers in SOAP::WSDL inherit from this class.
2133            
2134             =head1 AUTHOR
2135            
2136             Replace the whitespace by @ for E-Mail Address.
2137            
2138             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
2139            
2140             =head1 LICENSE AND COPYRIGHT
2141            
2142             Copyright 2004-2007 Martin Kutter.
2143            
2144             This file is part of SOAP-WSDL. You may distribute/modify it under
2145             the same terms as perl itself
2146            
2147             =head1 Repository information
2148            
2149             $Id: $
2150            
2151             $LastChangedDate: 2007-09-10 18:19:23 +0200 (Mo, 10 Sep 2007) $
2152             $LastChangedRevision: 218 $
2153             $LastChangedBy: kutterma $
2154            
2155             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/MessageParser.pm $
2156             SOAP_WSDL_EXPAT_BASE
2157              
2158 6         15 $fatpacked{"SOAP/WSDL/Expat/Message2Hash.pm"} =
2159             <<'SOAP_WSDL_EXPAT_MESSAGE2HASH';
2160             #!/usr/bin/perl
2161             package
2162             SOAP::WSDL::Expat::Message2Hash;
2163             use strict;
2164             use warnings;
2165             use base qw(SOAP::WSDL::Expat::Base);
2166            
2167             use version; our $VERSION = qv('2.00.99_3');
2168            
2169             sub _initialize {
2170             my ($self, $parser) = @_;
2171             $self->{ parser } = $parser;
2172             delete $self->{ data }; # remove potential old results
2173            
2174             my $characters;
2175             my $current = {};
2176             my $list = []; # node list
2177             my $current_part = q{}; # are we in header or body ?
2178             $self->{ data } = $current;
2179            
2180             # use "globals" for speed
2181             my ($_element, $_method,
2182             $_class, $_parser, %_attrs) = ();
2183            
2184             # no strict qw(refs);
2185             $parser->setHandlers(
2186             Start => sub {
2187             push @$list, $current;
2188             #If our element exists and is a list ref, add to it
2189             if ( exists $current->{ $_[1] }
2190             && ( ref ($current->{ $_[1] }) eq 'ARRAY')
2191             ) {
2192             push @{ $current->{ $_[1] } }, {};
2193             $current = $current->{ $_[1] }->[-1];
2194             }
2195             elsif ( exists $current->{ $_[1] } )
2196             {
2197             $current->{ $_[1] } = [ $current->{ $_[1] }, {} ];
2198             $current = $current->{ $_[1] }->[-1];
2199             }
2200             else {
2201             $current->{ $_[1] } = {};
2202             $current = $current->{ $_[1] };
2203             }
2204             return;
2205             },
2206            
2207             Char => sub {
2208             $characters .= $_[1] if $_[1] !~m{ \A \s* \z}xms;
2209             return;
2210             },
2211            
2212             End => sub {
2213             $_element = $_[1];
2214            
2215             # This one easily handles ignores for us, too...
2216             # return if not ref $$list[-1];
2217            
2218             if (length $characters) {
2219             if (ref $list->[-1]->{ $_element } eq 'ARRAY') {
2220             $list->[-1]->{ $_element }->[-1] = $characters ;
2221             }
2222             else {
2223             $list->[-1]->{ $_element } = $characters;
2224             }
2225             }
2226             $characters = q{};
2227             $current = pop @$list; # step up in object hierarchy...
2228             return;
2229             }
2230             );
2231             return $parser;
2232             }
2233            
2234             1;
2235            
2236             =pod
2237            
2238             =head1 NAME
2239            
2240             SOAP::WSDL::Expat::Message2Hash - Convert SOAP messages to perl hash refs
2241            
2242             =head1 SYNOPSIS
2243            
2244             my $parser = SOAP::WSDL::Expat::MessageParser->new({
2245             class_resolver => 'My::Resolver'
2246             });
2247             $parser->parse( $xml );
2248             my $obj = $parser->get_data();
2249            
2250             =head1 DESCRIPTION
2251            
2252             Real fast expat based SOAP message parser.
2253            
2254             See L<SOAP::WSDL::Manual::Parser> for details.
2255            
2256             =head1 Bugs and Limitations
2257            
2258             =over
2259            
2260             =item * Ignores all namespaces
2261            
2262             =item * Ignores all attributes
2263            
2264             =item * Does not handle mixed content
2265            
2266             =item * The SOAP header is ignored
2267            
2268             =back
2269            
2270             =head1 AUTHOR
2271            
2272             Replace the whitespace by @ for E-Mail Address.
2273            
2274             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
2275            
2276             =head1 LICENSE AND COPYRIGHT
2277            
2278             Copyright 2004-2007 Martin Kutter.
2279            
2280             This file is part of SOAP-WSDL. You may distribute/modify it under
2281             the same terms as perl itself
2282            
2283             =head1 Repository information
2284            
2285             $Id: $
2286            
2287             $LastChangedDate: 2007-09-10 18:19:23 +0200 (Mo, 10 Sep 2007) $
2288             $LastChangedRevision: 218 $
2289             $LastChangedBy: kutterma $
2290            
2291             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/MessageParser.pm $
2292            
2293             SOAP_WSDL_EXPAT_MESSAGE2HASH
2294              
2295 6         13 $fatpacked{"SOAP/WSDL/Expat/MessageParser.pm"} =
2296             <<'SOAP_WSDL_EXPAT_MESSAGEPARSER';
2297             #!/usr/bin/perl
2298             package
2299             SOAP::WSDL::Expat::MessageParser;
2300             use strict; use warnings;
2301            
2302             use SOAP::WSDL::Generator::PrefixResolver;
2303             use SOAP::WSDL::XSD::Typelib::Builtin;
2304             use SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType;
2305             use SOAP::WSDL::XSD::Typelib::ComplexType;
2306             use base qw(SOAP::WSDL::Expat::Base);
2307            
2308             BEGIN { require Class::Std::Fast };
2309            
2310             our $VERSION = 2.01;
2311            
2312             # GLOBALS
2313             my $OBJECT_CACHE_REF = Class::Std::Fast::OBJECT_CACHE_REF();
2314             my $CLASSES_OF_REF = $SOAP::WSDL::XSD::Typelib::ComplexType::___classes_of_ref;
2315            
2316             # keep track of classes loaded
2317             my %LOADED_OF = ();
2318            
2319             sub new {
2320             my ($class, $args) = @_;
2321             my $self = {
2322             prefix_resolver => $args->{ prefix_resolver } || SOAP::WSDL::Generator::PrefixResolver->new(),
2323             class_resolver => $args->{ class_resolver },
2324             body_parts => $args->{ body_parts } || [],
2325             header_parts => $args->{ header_parts } || [],
2326             strict => exists $args->{ strict } ? $args->{ strict } : 1,
2327             };
2328            
2329             bless $self, $class;
2330            
2331             $self->load_classes()
2332             if $args->{ class_resolver }
2333             && ! exists $LOADED_OF{ $self->{ class_resolver } };
2334            
2335             return $self;
2336             }
2337            
2338             sub set_header_parts {
2339             $_[0]->{ header_parts } = $_[1];
2340             }
2341            
2342             sub set_body_parts {
2343             $_[0]->{ body_parts } = $_[1];
2344             }
2345            
2346             sub class_resolver {
2347             my $self = shift;
2348             if ( @_ ) {
2349             $self->{ class_resolver } = shift
2350             or return;
2351             $self->load_classes() if ! exists $LOADED_OF{ $self->{ class_resolver } };
2352             }
2353             return $self->{ class_resolver };
2354             }
2355            
2356             sub load_classes {
2357             my $self = shift;
2358            
2359             return if $LOADED_OF{ $self->{ class_resolver } }
2360             || ! $self->{ class_resolver }->can('get_typemap');
2361            
2362             # requires sorting to make sub-packages load after their parent
2363             for ( sort values %{ $self->{ class_resolver }->get_typemap() } ) {
2364             no strict qw(refs);
2365             my $class = $_;
2366            
2367             # ignore __SKIP__
2368             next if $class eq '__SKIP__';
2369            
2370             # check if namespace exists
2371             next if defined *{ "$class\::" }; # bad test - know a better one?
2372            
2373             # Require takes a bareword or a file name - we have to take
2374             # the filname road here...
2375             $class =~s{ :: }{/}xmsg;
2376             require "$class.pm";
2377             }
2378             $LOADED_OF{ $self->{ class_resolver } } = 1;
2379             }
2380            
2381             sub get_type_class {
2382             my ($self, $name) = @_;
2383             my ($prefix,$localname) = split m{:}x , $name;
2384             my $namespace;
2385             if ($localname) {
2386             $namespace = $self->{ parser }->expand_ns_prefix($prefix);
2387             }
2388             else {
2389             $namespace = $self->{ parser }->expand_ns_prefix('#default');
2390             $localname = $name;
2391             }
2392            
2393             return "SOAP::WSDL::XSD::Typelib::Builtin::$localname"
2394             if ($namespace eq 'http://www.w3.org/2001/XMLSchema');
2395            
2396             # resolve perl prefix
2397             my $perl_prefix = $self->{ prefix_resolver }->resolve_prefix('type', $namespace);
2398            
2399             # TODO build a perl name from >type< prefix and name using the prefix resolver
2400             return "$perl_prefix$localname";
2401             }
2402            
2403             sub _initialize {
2404             my ($self, $parser) = @_;
2405             $self->{ parser } = $parser;
2406            
2407             delete $self->{ data }; # remove potential old results
2408             delete $self->{ header };
2409            
2410             # Note: $current MUST be undef - it is used as sentinel
2411             # on the object stack via if (! defined $list->[-1])
2412             # DON'T set it to anything else !
2413             my $current = undef;
2414            
2415             my ($list, $path) = ([], []); # node list (object stack) and path
2416             my ($skip, $depth) = (0, 0); # skip elements, depth
2417            
2418             # use "globals" for speed
2419             my ($_prefix, $_method, $_class, $_leaf, $characters, $_current_classes_of_ref, $handling_multiple_parts) = ();
2420             my (@_attr_from, %_xsi_attr_of) = ();
2421            
2422             my %parts_of = (
2423             body => {
2424             map {
2425             exists $LOADED_OF{ $_ }
2426             || eval "require $_" and $LOADED_OF{ $_ } = undef;
2427             $_->__get_name() => $_
2428             } @{ $self->{ body_parts } }
2429             },
2430             header => {
2431             map {
2432             exists $LOADED_OF{ $_ }
2433             || eval "require $_" and $LOADED_OF{ $_ } = undef;
2434             eval "require $_"; $_->__get_name() => $_
2435             } @{ $self->{ header_parts } }
2436             }
2437             );
2438            
2439             my %content_check = (
2440             0 => sub {
2441             die "Bad top node $_[1]" if $_[1] ne 'Envelope';
2442             die "Bad namespace for SOAP envelope: " . $_[0]->recognized_string()
2443             if $_[0]->namespace($_[1]) ne 'http://schemas.xmlsoap.org/soap/envelope/';
2444             $depth++;
2445             },
2446             1 => sub {
2447             $depth++;
2448             if ($_[1] eq 'Body') {
2449             if ( exists $self->{data} ) { # there was header data
2450             $self->{ header } = delete $self->{ data };
2451             $list = [];
2452             $path = [];
2453             undef $current;
2454             }
2455             $handling_multiple_parts = @{ $self->{body_parts} } > 1;
2456             $_current_classes_of_ref = $parts_of{ body };
2457             }
2458             elsif ($_[1] eq 'Header') {
2459             $handling_multiple_parts = @{ $self->{header_parts} } > 1;
2460             $_current_classes_of_ref = $parts_of{ header };
2461             }
2462             },
2463             );
2464             # bypass checking wheter namespaces are OK in non-strict mode
2465             if (! $self->{strict}) {
2466             $content_check{0} = sub { $depth++ };
2467             }
2468             my $char_handler = sub {
2469             return if ! $_leaf; # we only want characters in leaf nodes
2470             $characters .= $_[1]; # add to characters
2471             return; # return void
2472             };
2473            
2474             my $start_handler = sub {
2475             # my ($parser, $element, %attrs) = @_;
2476             $_leaf = 1; # believe we're a leaf node until we see an end
2477            
2478             # call methods without using their parameter stack. That's slightly
2479             # faster than $content_check{ $depth }->() and we don't have to pass
2480             # $_[1] to the method.
2481             return &{$content_check{ $depth }} if exists $content_check{ $depth };
2482            
2483             $depth++;
2484             return if ($skip);
2485             # handle attributes
2486             # Attribute names must not be converted into hash keys - they're
2487             # dual-valued scalars, and loose their second value when converted
2488             # to a hash key...
2489             %_xsi_attr_of = ();
2490             if (@_ > 2) {
2491             @_attr_from = @_[2..$#_];
2492            
2493             # handle xsi attributes
2494             # looks pretty C-ish - but those dual vars don't leave much choice
2495             my $i = 0;
2496             while ($i < @_attr_from) {
2497             if ( ( $_[0]->namespace($_attr_from[$i]) || q{} ) eq 'http://www.w3.org/2001/XMLSchema-instance') {
2498             $_xsi_attr_of{$_attr_from[$i]} = $_attr_from[$i + 1];
2499             splice @_attr_from, $i, 2;
2500             }
2501             $i += 2;
2502             }
2503             }
2504            
2505             # we only need to set $_current_classes_of if we may have child nodes
2506             # set new class resolver
2507            
2508             # get class from current complexType
2509             $_class = exists $_xsi_attr_of{type}
2510             ? $self->get_type_class($_xsi_attr_of{type})
2511             : ( $_current_classes_of_ref->{ $_[1] });
2512            
2513             # When no class is found: throw error in strict mode
2514             # and enable skipping in lax mode. Be sure not to move
2515             # this block not below pushing stuff on @{ $list } - the
2516             # list contains a sentinel used as stop marker for
2517             # returning content (instead of adding it to a parent)
2518             if (! defined($_class) ) {
2519             if ($self->{ strict }) {
2520             die "Cannot resolve class for element " . $_[1];
2521             }
2522             $skip = $depth;
2523             $_[0]->setHandlers( Char => undef );
2524             return;
2525             }
2526            
2527             # step down in tree
2528             # on the first object (after skipping Envelope/Body), $current
2529             # is undef. We put it on the stack, anyway, and use it as sentinel
2530             # when going through the closing tags in the End handler
2531             push @{ $list }, $current; # remember current
2532             push @{ $path }, $_current_classes_of_ref; # remember class map
2533            
2534             # all Builtins are simple types
2535             # complexTypes need to look up their child's element map...
2536             COMPLEX: {
2537             if ( $_class !~ m{ SOAP::WSDL::XSD::Typelib::Builtin:: }x ) {
2538             if ( exists $CLASSES_OF_REF->{ $_class } ) {
2539             $_current_classes_of_ref = $CLASSES_OF_REF->{ $_class };
2540             last COMPLEX;
2541             }
2542            
2543             # try parent classes - walk through isa
2544             # only elements need to walk through @ISA
2545             $_class->isa('SOAP::WSDL::XSD::Typelib::Element')
2546             or last COMPLEX;
2547            
2548             # follow @ISA depth first
2549             no strict qw(refs);
2550             my @isa = @{ "$_class\::ISA" };
2551             ISA: {
2552             do {
2553             if ( exists $CLASSES_OF_REF->{ $isa[0] } ) {
2554             $_current_classes_of_ref = $CLASSES_OF_REF->{ $isa[0] };
2555             last ISA;
2556             }
2557            
2558             unshift @isa, @{ shift(@isa) . '::ISA'};
2559             } until ($#isa < 0);
2560             }
2561             }
2562             }
2563            
2564             # cleanup
2565             undef $current; # help profilers find real hot spots
2566             $characters = q{};
2567            
2568             # Create and set new objects using Class::Std::Fast's object cache
2569             # if possible, or blessing directly into the class in question
2570             # (circumventing constructor) here. That's dirty, but fast.
2571             #
2572             # TODO: check whether this is faster under all perls - there's
2573             # strange benchmark results...
2574             #
2575             # The alternative would read:
2576             # $current = $_class->new({ @_[2..$#_] });
2577            
2578             $current = pop @{ $OBJECT_CACHE_REF->{ $_class } };
2579             if ( ! defined $current ) {
2580             $current = bless \Class::Std::Fast::ID(), $_class;
2581             }
2582            
2583             # ahm - ain't this better off in a end handler?
2584             if ( $_xsi_attr_of{nil} && $_xsi_attr_of{nil} ne 'false' ) {
2585             undef $characters;
2586             }
2587            
2588             # set attributes if there are any
2589             $current->attr({ @_attr_from }) if @_attr_from;
2590             # $depth++;
2591            
2592             # return is only half as fast as no statement - however,
2593             # XML::Parser::Expat accidentally calls the callbacks in
2594             # scalar (instead of void) context, making return faster
2595             return;
2596             };
2597            
2598             # compatibility start handler for use with typemaps
2599             my $start_handler_typemap = sub {
2600             # my ($parser, $element, %attrs) = @_;
2601            
2602             $_leaf = 1; # believe we're a leaf node until we see an end
2603            
2604             # call methods without using their parameter stack
2605             # That's slightly faster than $content_check{ $depth }->()
2606             # and we don't have to pass $_[1] to the method.
2607             # Yup, that's dirty.
2608             return &{$content_check{ $depth }}
2609             if exists $content_check{ $depth };
2610            
2611             push @{ $path }, $_[1]; # step down in path
2612             return if $skip; # skip inside __SKIP__
2613            
2614             # resolve class of this element
2615             $_class = $self->{ class_resolver }->get_class( $path );
2616            
2617             if (! defined($_class) and $self->{ strict }) {
2618             die "Cannot resolve class for element "
2619             . join('/', @{ $path }) . " via " . $self->{ class_resolver };
2620             }
2621            
2622             if (! defined($_class) or ($_class eq '__SKIP__') ) {
2623             $skip = scalar @{ $path };
2624             $_[0]->setHandlers( Char => undef );
2625             return;
2626             }
2627            
2628             # step down in tree (remember current)
2629             #
2630             # on the first object (after skipping Envelope/Body), $current
2631             # is undef.
2632             # We put it on the stack, anyway, and use it as sentinel when
2633             # going through the closing tags in the End handler
2634             #
2635             push @{$list}, $current;
2636            
2637             # cleanup.
2638             undef $current; # help profilers find the real hot spots
2639             $characters = q{}; # reset characters read
2640            
2641             # Create and set new objects using Class::Std::Fast's object cache
2642             # if possible, or blessing directly into the class in question
2643             # (circumventing constructor) here.
2644             # That's dirty, but fast.
2645             #
2646             # TODO: check whether this is faster under all perls - there's
2647             # strange benchmark results...
2648             #
2649             # The alternative would read:
2650             # $current = $_class->new({ @_[2..$#_] });
2651             #
2652             $current = pop @{ $OBJECT_CACHE_REF->{ $_class } };
2653             if ( ! defined $current ) {
2654             $current = bless \Class::Std::Fast::ID(), $_class;
2655             }
2656            
2657             # set attributes if there are any
2658             ATTR: {
2659             my %attr = @_[2..$#_];
2660            
2661             if ( %attr ) {
2662             if ( my $nil = delete $attr{nil} ) {
2663             # TODO: check namespace
2664             if ($nil && $nil ne 'false') {
2665             undef $characters;
2666             last ATTR if ! %attr;
2667             }
2668             }
2669             $current->attr(\%attr);
2670             }
2671             }
2672             $depth++;
2673            
2674             return; # Speed up XML::Parser::Expat - see above for why
2675             };
2676            
2677             my $end_handler = sub {
2678             # operate on @_ for performance
2679            
2680             $_current_classes_of_ref = pop @{ $path }; # step up in path
2681             $depth--;
2682            
2683             # check $skip - do we have to come back?
2684             #
2685             # Skip is a marker for the depth of the element to skip.
2686             # If depth ever drops below this, remove marker
2687             # be sure not to move the $depth-- below this block
2688             if ($skip) {
2689             return if $skip < $depth;
2690             $skip = 0;
2691             $_[0]->setHandlers( Char => $char_handler );
2692             return;
2693             }
2694            
2695             # we only set character values in leaf nodes
2696             # Use dirty but fast access via global variables.
2697             # The normal way (via method) would be this:
2698             # $current->set_value( $characters ) if (length($characters));
2699             $SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType::___value
2700             ->{ ${$current} } = $characters
2701             if $_leaf && defined $characters && defined $current;
2702            
2703             # empty characters
2704             $characters = q{};
2705            
2706             # stop believing we're a leaf node
2707             undef $_leaf;
2708            
2709             # return if there's only one elment - can't set it in parent ;-)
2710             # but set as root element if we don't have one already.
2711             if ( defined $list->[-1] ) {
2712             # set appropriate attribute in last element
2713             # multiple values must be implemented in base class
2714             # TODO check if hash access is faster
2715             # $_method = "add_$_localname";
2716             $_method = "add_$_[1]";
2717            
2718             # fixup XML names for perl names
2719             $_method =~ s{\.}{__}xg;
2720             $_method =~ s{\-}{_}xg;
2721             $list->[-1]->$_method( $current );
2722            
2723             $current = pop @{$list}; # step up in object hierarchy
2724            
2725             undef $_leaf; # stop believing we're a leaf node
2726             }
2727             else {
2728             if ( $handling_multiple_parts ) {
2729             push @{$self->{data} ||= []}, $current;
2730             $current = ();
2731             }
2732             elsif ( ! exists $self->{ data } ) {
2733             $self->{data} = $current;
2734             }
2735             # TODO: Skip content of anyType / any stuff
2736             }
2737            
2738             return; # Speed up XML::Parser::Expat - see above for why
2739             };
2740            
2741             my $end_handler_typemap = sub {
2742             pop @{ $path }; # step up in path
2743             # check __SKIP__
2744             if ($skip) {
2745             return if $skip < scalar @{ $path };
2746             $skip = 0;
2747             $_[0]->setHandlers( Char => $char_handler );
2748             return;
2749             }
2750            
2751             $depth--;
2752            
2753             # we only set character values in leaf nodes
2754             if (defined $_leaf) {
2755             # Use dirty but fast access via global variables.
2756             # The normal way (via method) would be this:
2757             # $current->set_value( $characters ) if (length($characters));
2758             $SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType::___value
2759             ->{ $$current } = $characters
2760             if defined $characters && defined $current; # =~m{ [^\s] }xms;
2761             }
2762            
2763             # empty characters
2764             $characters = q{};
2765            
2766             # stop believing we're a leaf node
2767             undef $_leaf;
2768            
2769             # return if there's only one elment - can't set it in parent ;-)
2770             # but set as root element if we don't have one already.
2771             if ( ! defined $list->[-1] ) {
2772             $self->{ data } = $current if ! exists $self->{ data };
2773             return;
2774             };
2775            
2776             # set appropriate attribute in last element
2777             # multiple values must be implemented in base class
2778             # TODO check if hash access is faster
2779             # $_method = "add_$_localname";
2780             $_method = "add_$_[1]";
2781            
2782             # fixup XML names for perl names
2783             $_method =~s{\.}{__}xg;
2784             $_method =~s{\-}{_}xg;
2785             $list->[-1]->$_method( $current );
2786            
2787             # step up in object hierarchy
2788             $current = pop @$list;
2789            
2790             # Speed up XML::Parser::Expat - calls handlers in scalar context...
2791             return;
2792             };
2793            
2794             no strict qw(refs);
2795             $parser->setHandlers(
2796             Start => @{ $self->{ body_parts } }
2797             ? $start_handler
2798             : $start_handler_typemap,
2799             Char => $char_handler,
2800             End => @{ $self->{ body_parts } }
2801             ? $end_handler
2802             : $end_handler_typemap,
2803             );
2804            
2805             return $parser;
2806             }
2807            
2808             sub get_header {
2809             return $_[0]->{ header };
2810             }
2811            
2812             1;
2813            
2814             =pod
2815            
2816             =head1 NAME
2817            
2818             SOAP::WSDL::Expat::MessageParser - Convert SOAP messages to custom object trees
2819            
2820             =head1 SYNOPSIS
2821            
2822             my $parser = SOAP::WSDL::Expat::MessageParser->new({
2823             class_resolver => 'My::Resolver'
2824             });
2825             $parser->parse( $xml );
2826             my $obj = $parser->get_data();
2827            
2828             =head1 DESCRIPTION
2829            
2830             Real fast expat based SOAP message parser.
2831            
2832             See L<SOAP::WSDL::Manual::Parser> for details.
2833            
2834             =head2 Skipping unwanted items
2835            
2836             Skipping unwanted items only works with typemaps.
2837            
2838             The use of typemaps is discouraged from SOAP::WSDL 2.01 on. The typemap
2839             mechanism will become deprecated and eventually dropped in future versions of
2840             SOAP::WSDL.
2841            
2842             The information below is just there for completeness.
2843            
2844             Sometimes there's unneccessary information transported in SOAP messages.
2845            
2846             To skip XML nodes (including all child nodes), just edit the type map for
2847             the message, set the type map entry to '__SKIP__', and comment out all
2848             child elements you want to skip.
2849            
2850             =head1 Bugs and Limitations
2851            
2852             =over
2853            
2854             =item * Ignores all namespaces
2855            
2856             =item * Does not handle mixed content
2857            
2858             =item * The SOAP header is ignored
2859            
2860             =back
2861            
2862             =head1 AUTHOR
2863            
2864             Replace the whitespace by @ for E-Mail Address.
2865            
2866             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
2867            
2868             =head1 LICENSE AND COPYRIGHT
2869            
2870             Copyright 2004-2008 Martin Kutter.
2871            
2872             This file is part of SOAP-WSDL. You may distribute/modify it under
2873             the same terms as perl itself
2874            
2875             =head1 Repository information
2876            
2877             $Id: MessageParser.pm 840 2009-03-09 20:17:15Z kutterma $
2878            
2879             $LastChangedDate: 2009-03-09 14:17:15 -0600 (Mon, 09 Mar 2009) $
2880             $LastChangedRevision: 840 $
2881             $LastChangedBy: kutterma $
2882            
2883             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Expat/MessageParser.pm $
2884            
2885             SOAP_WSDL_EXPAT_MESSAGEPARSER
2886              
2887 6         22 $fatpacked{"SOAP/WSDL/Expat/MessageStreamParser.pm"} =
2888             <<'SOAP_WSDL_EXPAT_MESSAGESTREAMPARSER';
2889             #!/usr/bin/perl
2890             package
2891             SOAP::WSDL::Expat::MessageStreamParser;
2892             use strict;
2893             use warnings;
2894             use XML::Parser::Expat;
2895             use SOAP::WSDL::Expat::MessageParser;
2896             use base qw(SOAP::WSDL::Expat::MessageParser);
2897            
2898             use version; our $VERSION = qv('2.00.99_3');
2899            
2900             sub parse_start {
2901             my $self = shift;
2902             $self->{ parser } = $_[0]->_initialize( XML::Parser::ExpatNB->new( Namespaces => 1 ) );
2903             }
2904             sub init;
2905             *init = \&parse_start;
2906            
2907             sub parse_more {
2908             $_[0]->{ parser }->parse_more( $_[1] );
2909             }
2910            
2911             sub parse_done {
2912             $_[0]->{ parser }->parse_done();
2913             $_[0]->{ parser }->release();
2914             }
2915            
2916             1;
2917            
2918             =pod
2919            
2920             =head1 NAME
2921            
2922             SOAP::WSDL::Expat::MessageStreamParser - Convert SOAP messages to custom object trees
2923            
2924             =head1 SYNOPSIS
2925            
2926             my $lwp = LWP::UserAgent->new();
2927            
2928             my $parser = SOAP::WSDL::Expat::MessageParser->new({
2929             class_resolver => 'My::Resolver'
2930             });
2931             my $chunk_parser = $parser->init();
2932             # process response while it comes in, trying to read 32k chunks.
2933             $lwp->request( $request, sub { $chunk_parser->parse_more($_[0]) } , 32468 );
2934             $chunk_parser->parse_done();
2935            
2936             my $obj = $parser->get_data();
2937            
2938             =head1 DESCRIPTION
2939            
2940             ExpatNB based parser for parsing huge documents.
2941            
2942             See L<SOAP::WSDL::Manual::Parser> for details.
2943            
2944             =head1 Bugs and Limitations
2945            
2946             See SOAP::WSDL::Expat::MessageParser
2947            
2948             =head1 AUTHOR
2949            
2950             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
2951            
2952             =head1 LICENSE AND COPYRIGHT
2953            
2954             Copyright 2007 Martin Kutter.
2955            
2956             This file is part of SOAP-WSDL. You may distribute/modify it under
2957             the same terms as perl itself
2958            
2959             =head1 REPOSITORY INFORMATION
2960            
2961             $Rev: 861 $
2962             $LastChangedBy: kutterma $
2963             $Id: MessageStreamParser.pm 861 2010-03-28 10:41:26Z kutterma $
2964             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Expat/MessageStreamParser.pm $
2965            
2966             =cut
2967             SOAP_WSDL_EXPAT_MESSAGESTREAMPARSER
2968              
2969 6         57 $fatpacked{"SOAP/WSDL/Expat/WSDLParser.pm"} =
2970             <<'SOAP_WSDL_EXPAT_WSDLPARSER';
2971             package
2972             SOAP::WSDL::Expat::WSDLParser;
2973             use strict;
2974             use warnings;
2975             use Carp;
2976             use SOAP::WSDL::TypeLookup;
2977             use base qw(SOAP::WSDL::Expat::Base);
2978            
2979             use version; our $VERSION = qv('2.00.99_3');
2980            
2981             #
2982             # Import child elements of a WSDL / XML Schema tree into the current tree
2983             #
2984             # Set the targetNamespace of the imported nodes to $import_namespace
2985             #
2986             # SYNOPSIS
2987             #
2988             # $self->_import_children($name, $imported, $imported, $import_namespace)
2989             #
2990            
2991             sub _import_children {
2992             my ( $self, $name, $imported, $importer, $import_namespace ) = @_;
2993            
2994             my $targetNamespace = $importer->get_targetNamespace();
2995             my $push_method = "push_$name";
2996             my $get_method = "get_$name";
2997             my $default_namespace = $imported->get_xmlns()->{'#default'};
2998            
2999             no strict qw(refs);
3000             my $value_ref = $imported->$get_method();
3001             if ($value_ref) {
3002            
3003             $value_ref = [$value_ref] if ( not ref $value_ref eq 'ARRAY' );
3004            
3005             for ( @{$value_ref} ) {
3006            
3007             # fixup namespace - new parent may be from different namespace
3008             if ( defined($default_namespace) ) {
3009             my $xmlns = $_->get_xmlns();
3010            
3011             # it's a hash ref, so we can just update values
3012             if ( !defined $xmlns->{'#default'} ) {
3013             $xmlns->{'#default'} = $default_namespace;
3014             }
3015             }
3016            
3017             # fixup targetNamespace, but don't override
3018             $_->set_targetNamespace($import_namespace)
3019             if ( ( $import_namespace ne $targetNamespace )
3020             && !$_->get_targetNamespace );
3021            
3022             # update parent...
3023             $_->set_parent($importer);
3024            
3025             # push elements into importing WSDL
3026             $importer->$push_method($_);
3027             }
3028             }
3029             }
3030            
3031             sub _import_namespace_definitions {
3032             my $self = shift;
3033             my $arg_ref = shift;
3034             my $importer = $arg_ref->{importer};
3035             my $imported = $arg_ref->{imported};
3036            
3037             # import namespace definitions, too
3038             my $importer_ns_of = $importer->get_xmlns();
3039             my %xmlns_of = %{$imported->get_xmlns()};
3040            
3041             # it's a hash ref, we can just add to.
3042             # TODO: check whether URI is the better key.
3043             while ( my ( $prefix, $url ) = each %xmlns_of ) {
3044             if ( exists( $importer_ns_of->{$prefix} ) ) {
3045            
3046             # warn "$prefix already exists";
3047             next;
3048             }
3049             $importer_ns_of->{$prefix} = $url;
3050             }
3051             }
3052            
3053             sub xml_schema_import {
3054             my $self = shift;
3055             my $schema = shift;
3056             my $parser = $self->clone();
3057             my %attr_of = @_;
3058             my $import_namespace = $attr_of{namespace};
3059            
3060             if ( not $attr_of{schemaLocation} ) {
3061             warn
3062             "cannot import document for namespace >$import_namespace< without location";
3063             return;
3064             }
3065            
3066             if ( not $self->get_uri ) {
3067             die
3068             "cannot import document from namespace >$import_namespace< without base uri. Use >parse_uri< or >set_uri< to set one.";
3069             }
3070            
3071             my $uri = URI->new_abs( $attr_of{schemaLocation}, $self->get_uri() );
3072             my $imported = $parser->parse_uri($uri);
3073            
3074             # might already be imported - parse_uri just returns in this case
3075             return if not defined $imported;
3076            
3077             $self->_import_namespace_definitions( {
3078             importer => $schema,
3079             imported => $imported,
3080             } );
3081            
3082             for my $name (qw(type element group attribute attributeGroup)) {
3083             $self->_import_children( $name, $imported, $schema,
3084             $import_namespace );
3085             }
3086             }
3087            
3088             sub wsdl_import {
3089             my $self = shift;
3090             my $definitions = shift;
3091             my $parser = $self->clone();
3092             my %attr_of = @_;
3093             my $import_namespace = $attr_of{namespace};
3094            
3095             if ( not $attr_of{location} ) {
3096             warn
3097             "cannot import document for namespace >$import_namespace< without location";
3098             return;
3099             }
3100            
3101             if ( not $self->get_uri ) {
3102             die
3103             "cannot import document from namespace >$import_namespace< without base uri. Use >parse_uri< or >set_uri< to set one.";
3104             }
3105            
3106             my $uri = URI->new_abs( $attr_of{location}, $self->get_uri() );
3107            
3108             my $imported = $parser->parse_uri($uri);
3109            
3110             # might already be imported - parse_uri just returns in this case
3111             return if not defined $imported;
3112            
3113             $self->_import_namespace_definitions( {
3114             importer => $definitions,
3115             imported => $imported,
3116             } );
3117            
3118             for my $name (qw(types message binding portType service)) {
3119             $self->_import_children( $name, $imported, $definitions,
3120             $import_namespace );
3121             }
3122             }
3123            
3124             sub _initialize {
3125             my ( $self, $parser ) = @_;
3126            
3127             # init object data
3128             $self->{parser} = $parser;
3129             delete $self->{data};
3130            
3131             # setup local variables for keeping temp data
3132             my $characters = undef;
3133             my $current = undef;
3134             my $list = []; # node list
3135             my $elementFormQualified = 1; # default for WSDLs, schema may override
3136            
3137             # TODO skip non-XML Schema namespace tags
3138             $parser->setHandlers(
3139             Start => sub {
3140            
3141             # handle attrs as list - expat uses dual-vars for looking
3142             # up namespace information, and hash keys don't allow dual vars...
3143             my ( $parser, $localname, @attrs ) = @_;
3144             $characters = q{};
3145            
3146             my $action =
3147             SOAP::WSDL::TypeLookup->lookup( $parser->namespace($localname),
3148             $localname );
3149            
3150             return if not $action;
3151            
3152             if ( $action->{type} eq 'CLASS' ) {
3153             eval "require $action->{ class }";
3154             croak $@ if ($@);
3155            
3156             my $obj = $action->{class}->new( {
3157             parent => $current,
3158             namespace => $parser->namespace($localname),
3159             defined($current)
3160             # make a copy of xmlns - don't let it be changed
3161             ? ( xmlns => { %{ $current->get_xmlns() } } )
3162             : ()} )->init( _fixup_attrs( $parser, @attrs ) );
3163            
3164             if ($current) {
3165             if ( defined $list->[-1]
3166             && $list->[-1]->isa('SOAP::WSDL::XSD::Schema') ) {
3167             $elementFormQualified =
3168             $list->[-1]->get_elementFormDefault() eq
3169             'qualified';
3170             }
3171            
3172             # inherit namespace, but don't override
3173             if ($elementFormQualified) {
3174             $obj->set_targetNamespace(
3175             $current->get_targetNamespace() )
3176             if not $obj->get_targetNamespace();
3177             }
3178            
3179             # push on parent's element/type list
3180             my $method = "push_$localname";
3181            
3182             no strict qw(refs);
3183             $current->$method($obj);
3184            
3185             # remember element for stepping back
3186             push @{$list}, $current;
3187             }
3188            
3189             # set new element (step down)
3190             $current = $obj;
3191             }
3192             elsif ( $action->{type} eq 'PARENT' ) {
3193             $current->init( _fixup_attrs( $parser, @attrs ) );
3194             }
3195             elsif ( $action->{type} eq 'METHOD' ) {
3196             my $method = $action->{method};
3197            
3198             no strict qw(refs);
3199            
3200             # call method with
3201             # - default value ($action->{ value } if defined,
3202             # dereferencing lists
3203             # - the values of the elements Attributes hash
3204             # TODO: add namespaces declared to attributes.
3205             # Expat consumes them, so we have to re-add them here.
3206             $current->$method(
3207             defined $action->{value}
3208             ? ref $action->{value}
3209             ? @{$action->{value}}
3210             : ( $action->{value} )
3211             : _fixup_attrs( $parser, @attrs ) );
3212             }
3213             elsif ( $action->{type} eq 'HANDLER' ) {
3214             my $method = $self->can( $action->{method} );
3215             $method->( $self, $current, @attrs );
3216             }
3217             else {
3218            
3219             # TODO replace by hash lookup of known namespaces.
3220             my $namespace = $parser->namespace($localname) || q{};
3221             my $part =
3222             $namespace eq 'http://schemas.xmlsoap.org/wsdl/'
3223             ? 'WSDL 1.1'
3224             : 'XML Schema';
3225            
3226             warn "$part element <$localname> is not implemented yet"
3227             if ( $localname !~
3228             m{ \A (:? annotation | documentation ) \z }xms );
3229             }
3230            
3231             return;
3232             },
3233            
3234             Char => sub { $characters .= $_[1]; return; },
3235            
3236             End => sub {
3237             my ( $parser, $localname ) = @_;
3238            
3239             my $action =
3240             SOAP::WSDL::TypeLookup->lookup( $parser->namespace($localname),
3241             $localname )
3242             || {};
3243            
3244             if ( !defined $list->[-1] ) {
3245             $self->{data} = $current;
3246             return;
3247             }
3248            
3249            
3250             return if not( $action->{type} );
3251             if ( $action->{type} eq 'CLASS' ) {
3252             $current = pop @{$list};
3253             if ( defined $list->[-1] && $list->[-1]->isa('SOAP::WSDL::XSD::Schema') ) {
3254             $elementFormQualified = 1;
3255             }
3256             }
3257             elsif ( $action->{type} eq 'CONTENT' ) {
3258             my $method = $action->{method};
3259            
3260             # normalize whitespace
3261             $characters =~ s{ ^ \s+ (.+) \s+ $ }{$1}xms;
3262             $characters =~ s{ \s+ }{ }xmsg;
3263            
3264             no strict qw(refs);
3265             $current->$method($characters);
3266             }
3267             return;
3268             } );
3269             return $parser;
3270             }
3271            
3272             # make attrs SAX style
3273             sub _fixup_attrs {
3274             my ( $parser, @attrs ) = @_;
3275            
3276             my @attr_key_from = ();
3277             my @attr_value_from = ();
3278            
3279             while (@attrs) {
3280             push @attr_key_from, shift @attrs;
3281             push @attr_value_from, shift @attrs;
3282             }
3283            
3284             my @attrs_from;
3285            
3286             # add xmlns: attrs. expat eats them.
3287             #
3288             # add namespaces before attributes: Attributes may be namespace-qualified
3289             #
3290             push @attrs_from, map { {
3291             Name => "xmlns:$_",
3292             Value => $parser->expand_ns_prefix($_),
3293             LocalName => $_
3294             }
3295             } $parser->new_ns_prefixes();
3296            
3297             push @attrs_from, map { {
3298             Name => defined $parser->namespace($_)
3299             ? $parser->namespace($_) . '|' . $_
3300             : '|' . $_,
3301             Value => shift @attr_value_from, # $attrs_of{ $_ },
3302             LocalName => $_
3303             }
3304             } @attr_key_from;
3305            
3306             return @attrs_from;
3307             }
3308            
3309             1;
3310            
3311             =pod
3312            
3313             =head1 NAME
3314            
3315             SOAP::WSDL::Expat::WSDLParser - Parse WSDL files into object trees
3316            
3317             =head1 SYNOPSIS
3318            
3319             my $parser = SOAP::WSDL::Expat::WSDLParser->new();
3320             $parser->parse( $xml );
3321             my $obj = $parser->get_data();
3322            
3323             =head1 DESCRIPTION
3324            
3325             WSDL parser used by SOAP::WSDL.
3326            
3327             =head1 AUTHOR
3328            
3329             Replace the whitespace by @ for E-Mail Address.
3330            
3331             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
3332            
3333             =head1 LICENSE AND COPYRIGHT
3334            
3335             Copyright 2004-2007 Martin Kutter.
3336            
3337             This file is part of SOAP-WSDL. You may distribute/modify it under
3338             the same terms as perl itself
3339            
3340             =head1 Repository information
3341            
3342             $Id: WSDLParser.pm 861 2010-03-28 10:41:26Z kutterma $
3343            
3344             $LastChangedDate: 2010-03-28 04:41:26 -0600 (Sun, 28 Mar 2010) $
3345             $LastChangedRevision: 861 $
3346             $LastChangedBy: kutterma $
3347            
3348             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Expat/WSDLParser.pm $
3349            
3350             SOAP_WSDL_EXPAT_WSDLPARSER
3351              
3352 6         16 $fatpacked{"SOAP/WSDL/Factory/Deserializer.pm"} =
3353             <<'SOAP_WSDL_FACTORY_DESERIALIZER';
3354             package
3355             SOAP::WSDL::Factory::Deserializer;
3356             use strict;
3357             use warnings;
3358            
3359             use version; our $VERSION = qv('2.00.99_3');
3360            
3361             my %DESERIALIZER = (
3362             '1.1' => 'SOAP::WSDL::Deserializer::XSD',
3363             );
3364            
3365             # class method
3366             sub register {
3367             my ($class, $ref_type, $package) = @_;
3368             $DESERIALIZER{ $ref_type } = $package;
3369             }
3370            
3371             sub get_deserializer {
3372             my ($self, $args_of_ref) = @_;
3373             $args_of_ref->{ soap_version } ||= '1.1';
3374             # sanity check
3375             die "no deserializer registered for SOAP version $args_of_ref->{ soap_version }"
3376             if not exists ($DESERIALIZER{ $args_of_ref->{ soap_version } });
3377            
3378             # load module
3379             eval "require $DESERIALIZER{ $args_of_ref->{ soap_version } }"
3380             or die "Cannot load serializer $DESERIALIZER{ $args_of_ref->{ soap_version } }", $@;
3381            
3382             return $DESERIALIZER{ $args_of_ref->{ soap_version } }->new($args_of_ref);
3383             }
3384            
3385             1;
3386            
3387             SOAP_WSDL_FACTORY_DESERIALIZER
3388              
3389 6         14 $fatpacked{"SOAP/WSDL/Factory/Generator.pm"} =
3390             <<'SOAP_WSDL_FACTORY_GENERATOR';
3391             package
3392             SOAP::WSDL::Factory::Generator;
3393             use strict;
3394             use warnings;
3395            
3396             use version; our $VERSION = qv('2.00.99_3');
3397            
3398             my %GENERATOR = (
3399             'XSD' => 'SOAP::WSDL::Generator::Template::XSD',
3400             );
3401            
3402             # class method
3403             sub register {
3404             my ($class, $ref_type, $package) = @_;
3405             $GENERATOR{ $ref_type } = $package;
3406             }
3407            
3408             sub get_generator {
3409             my ($self, $args_of_ref) = @_;
3410            
3411             # sanity check
3412             # die "no generator registered for generation method $args_of_ref->{ type }"
3413             #
3414             my $generator_class = (exists ($GENERATOR{ $args_of_ref->{ type } }))
3415             ? $GENERATOR{ $args_of_ref->{ type } }
3416             : $args_of_ref->{ type };
3417            
3418             # load module
3419             eval "require $generator_class"
3420             or die "Cannot load generator $generator_class", $@;
3421            
3422             return $generator_class->new();
3423             }
3424            
3425             1;
3426            
3427             SOAP_WSDL_FACTORY_GENERATOR
3428              
3429 6         14 $fatpacked{"SOAP/WSDL/Factory/Serializer.pm"} =
3430             <<'SOAP_WSDL_FACTORY_SERIALIZER';
3431             package
3432             SOAP::WSDL::Factory::Serializer;
3433             use strict;
3434             use warnings;
3435            
3436             use version; our $VERSION = qv('2.00.99_3');
3437            
3438             my %SERIALIZER = (
3439             '1.1' => 'SOAP::WSDL::Serializer::XSD',
3440             );
3441            
3442             # class method
3443             sub register {
3444             my ($class, $ref_type, $package) = @_;
3445             $SERIALIZER{ $ref_type } = $package;
3446             }
3447            
3448             sub get_serializer {
3449             my ($self, $args_of_ref) = @_;
3450             $args_of_ref->{ soap_version } ||= '1.1';
3451             # sanity check
3452             die "no serializer registered for SOAP version $args_of_ref->{ soap_version }"
3453             if not exists ($SERIALIZER{ $args_of_ref->{ soap_version } });
3454            
3455             # load module
3456             eval "require $SERIALIZER{ $args_of_ref->{ soap_version } }"
3457             or die "Cannot load serializer $SERIALIZER{ $args_of_ref->{ soap_version } }", $@;
3458            
3459             return $SERIALIZER{ $args_of_ref->{ soap_version } }->new();
3460             }
3461            
3462             1;
3463            
3464             SOAP_WSDL_FACTORY_SERIALIZER
3465              
3466 6         16 $fatpacked{"SOAP/WSDL/Factory/Transport.pm"} =
3467             <<'SOAP_WSDL_FACTORY_TRANSPORT';
3468             package
3469             SOAP::WSDL::Factory::Transport;
3470             use strict;
3471             use warnings;
3472             use version; our $VERSION = qv('2.00.99_3');
3473            
3474             my %registered_transport_of = ();
3475            
3476             # Local constants
3477             # Could be made readonly, but that's just for the paranoid...
3478             my %SOAP_LITE_TRANSPORT_OF = (
3479             ftp => 'SOAP::Transport::FTP',
3480             http => 'SOAP::Transport::HTTP',
3481             https => 'SOAP::Transport::HTTP',
3482             mailto => 'SOAP::Transport::MAILTO',
3483             'local' => 'SOAP::Transport::LOCAL',
3484             jabber => 'SOAP::Transport::JABBER',
3485             mq => 'SOAP::Transport::MQ',
3486             );
3487            
3488             my %SOAP_WSDL_TRANSPORT_OF = (
3489             http => 'SOAP::WSDL::Transport::HTTP',
3490             https => 'SOAP::WSDL::Transport::HTTP',
3491             );
3492            
3493             # class methods only
3494             sub register {
3495             my ($class, $scheme, $package) = @_;
3496             die "Cannot use reference as scheme" if ref $scheme;
3497             $registered_transport_of{ $scheme } = $package;
3498             }
3499            
3500             sub get_transport {
3501             my ($class, $url, %attrs) = @_;
3502            
3503            
3504             my $scheme = $url;
3505             $scheme =~s{ \:.+$ }{}xm;
3506            
3507            
3508             if (defined $registered_transport_of{ $scheme }) {
3509             no strict qw(refs);
3510             $registered_transport_of{ $scheme }->can('new') or
3511             eval "require $registered_transport_of{ $scheme }"
3512             or die "Cannot load transport class $registered_transport_of{ $scheme } : $@";
3513            
3514             # try "foo::Client" class first - SOAP::Tranport always requires
3515             # a package withoug the ::Client appended, and then
3516             # instantiates a ::Client object...
3517             # ... pretty weird ...
3518             # ... must be from some time when the max number of files was a
3519             # sparse resource ...
3520             # ... but we've decided to mimic SOAP::Lite...
3521            
3522             return $registered_transport_of{ $scheme }->new( %attrs );
3523             }
3524            
3525             # try SOAP::Lite's Transport module - just skip if not require'able
3526             SOAP_Lite: {
3527             if (exists $SOAP_LITE_TRANSPORT_OF{ $scheme }) {
3528             no strict qw(refs);
3529             # behaves interestingly different under different versions of perl
3530             # maybe true even if it's not available
3531             my $protocol_class = $SOAP_LITE_TRANSPORT_OF{ $scheme } . '::Client';
3532             $protocol_class->can('new')
3533             or eval "require $SOAP_LITE_TRANSPORT_OF{ $scheme }"
3534             or last SOAP_Lite;
3535            
3536             # may fail if it's not available
3537             my $transport = eval { $protocol_class->new( %attrs ) }
3538             or last SOAP_Lite;
3539             return $transport;
3540             }
3541             }
3542            
3543             if (exists $SOAP_WSDL_TRANSPORT_OF{ $scheme }) {
3544             no strict qw(refs);
3545             $SOAP_WSDL_TRANSPORT_OF{ $scheme }->can('new')
3546             or eval "require $SOAP_WSDL_TRANSPORT_OF{ $scheme }"
3547             or die "Cannot load transport class $SOAP_WSDL_TRANSPORT_OF{ $scheme } : $@";
3548             return $SOAP_WSDL_TRANSPORT_OF{ $scheme }->new( %attrs );
3549             }
3550            
3551             die "no transport class found for scheme <$scheme>";
3552             }
3553            
3554             1;
3555            
3556             SOAP_WSDL_FACTORY_TRANSPORT
3557              
3558 6         13 $fatpacked{"SOAP/WSDL/Generator/Iterator/WSDL11.pm"} =
3559             <<'SOAP_WSDL_GENERATOR_ITERATOR_WSDL11';
3560             package
3561             SOAP::WSDL::Generator::Iterator::WSDL11;
3562             use strict; use warnings;
3563             use Class::Std::Fast;
3564            
3565             use version; our $VERSION = qv('2.00.99_3');
3566            
3567             my %definitions_of :ATTR(:name<definitions> :default<[]>);
3568             my %nodes_of :ATTR(:name<nodes> :default<[]>);
3569            
3570             # memoization attributes
3571             my %portType_of :ATTR();
3572             my %types_of :ATTR();
3573            
3574             my %METHOD_OF = (
3575             'SOAP::WSDL::Definitions' => 'get_service',
3576             'SOAP::WSDL::Service' => 'get_port',
3577             'SOAP::WSDL::Port' => sub {
3578             my ($self, $node) = @_;
3579             return if ! $node->first_address()
3580             or ! $node->first_address()->isa('SOAP::WSDL::SOAP::Address');
3581            
3582             return [ $self->get_definitions()
3583             ->find_binding( $node->expand( $node->get_binding() ) ) || () ];
3584             },
3585            
3586             'SOAP::WSDL::Binding' => sub {
3587             my ($self, $node) = @_;
3588            
3589             # remember referenced portType
3590             $portType_of{ ident $self } = $self->get_definitions()
3591             ->find_portType( $node->expand( $node->get_type ) )
3592             or return [];
3593            
3594             return $node->get_operation();
3595             },
3596            
3597             'SOAP::WSDL::Operation' => sub {
3598             my ($self, $node) = @_;
3599            
3600             my $name = $node->get_name();
3601            
3602             # get the equally named operation from the portType
3603             my ($op) = grep { $_->get_name() eq $name }
3604             @{ $portType_of{ ident $self }->get_operation() }
3605             or return [];
3606            
3607             return [ @{ $op->get_input }, @{ $op->get_output }, @{ $op->get_fault } ]
3608             },
3609            
3610             'SOAP::WSDL::OpMessage' => sub {
3611             my ($self, $node) = @_;
3612             return if ( ref $node->get_parent() eq 'SOAP::WSDL::Binding' ); # we're in binding
3613            
3614             # TODO maybe allow more messages && overloading by specifying name
3615            
3616             return [ $self->get_definitions()->find_message(
3617             $node->expand( $node->get_message() )
3618             ) || () ];
3619             },
3620            
3621             'SOAP::WSDL::Message' => 'get_part',
3622            
3623             'SOAP::WSDL::Part' => sub {
3624             my ($self, $node) = @_;
3625             my $ident = ident $self;
3626             my $types = $types_of{ $ident } = $definitions_of{ $ident }->get_types()->[0]
3627             or return [];
3628             return [
3629             # If we have a type, this type is to be used in document/literal
3630             # as global type. However this is forbidden, at least by WS-I.
3631             # We should store the style/encoding somewhere, and regard it.
3632             # TODO: auto-generate element for RPC bindings
3633             $node->get_type()
3634             ? do {
3635             die "unsupported global type <"
3636             . $node->get_type . "> found in part <". $node->get_name() . ">\n"
3637             . "Looks like a rpc/literal WSDL, which is not supported by SOAP::WSDL\n";
3638             ## use this once we can auto-generate an element for RPC bindings
3639             # $types->find_type( $node->expand($node->get_type) )
3640             }
3641             : (),
3642             $node->get_element()
3643             ? $types->find_element( $node->expand($node->get_element) )
3644             : (),
3645             ];
3646             },
3647             );
3648            
3649             sub init {
3650             my ($self, $arg_of) = @_;
3651             my $ident = ident $self;
3652             undef $portType_of{ $ident };
3653             undef $types_of{ $ident };
3654             $nodes_of{ $ident } = [
3655             exists($arg_of->{ node })
3656             ? $arg_of->{ node }
3657             : $definitions_of{ ident $self }
3658             ];
3659             }
3660            
3661             sub get_next {
3662             my $self = shift;
3663             my $ident = ident $self;
3664            
3665             my $node = shift @{ $nodes_of{ $ident }};
3666             return if ! defined $node;
3667            
3668             unshift @{ $nodes_of{ $ident }}, @{ $self->get_nextNodes( $node ) || [] };
3669            
3670             return $node;
3671             }
3672            
3673             sub get_nextNodes {
3674             my ($self, $node) = @_;
3675            
3676             my $method = $METHOD_OF{ ref $node }
3677             or return [];
3678            
3679             return (ref($method) eq 'CODE')
3680             ? $method->( $self, $node )
3681             : $node->can($method)->( $node );
3682             }
3683            
3684             1;
3685            
3686             __END__
3687            
3688             =pod
3689            
3690             =head1 NAME
3691            
3692             SOAP::WSDL::Generator::Iterator::WSDL11 - WSDL 1.1 Iterator
3693            
3694             =head1 SYNOPSIS
3695            
3696             my $iter = SOAP::WSDL::Generator::Iterator::WSDL11->new({
3697             definitions => $wsdl
3698             });
3699             $iter->init();
3700             while (my $node = $iter->get_next()) {
3701             # do something with node - possibly call _accept with a visitor on it...
3702             }
3703            
3704             =head1 DESCRIPTION
3705            
3706             Iterator for walking a WSDL 1.1 definition.
3707            
3708             The iterator performs a depth-first search along the following path:
3709            
3710             service
3711             port
3712             binding
3713             operation
3714             input/output/fault of operation in portType
3715             message
3716             part
3717             type/element in XML schema
3718            
3719             If you wonder about this path: This is how to look up which XML Schema element
3720             is associated with a operation from a service/port.
3721            
3722             =head2 Example
3723            
3724             The nodes are returned in the order denoted in the following example:
3725            
3726             <?xml version="1.0" encoding="UTF-8"?>
3727             <!-- 1 -->
3728             <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
3729             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
3730             xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:HelloWorld"
3731             targetNamespace="urn:HelloWorld"
3732             xmlns="http://schemas.xmlsoap.org/wsdl/">
3733             <types>
3734             <s:schema elementFormDefault="qualified" targetNamespace="urn:HelloWorld">
3735             <!-- 9 -->
3736             <s:element name="sayHello">
3737             <s:complexType>
3738             <s:sequence>
3739             <s:element minOccurs="0" maxOccurs="1" name="name" type="s:string" />
3740             <s:element minOccurs="0" maxOccurs="1" name="givenName" type="s:string" nillable="1" />
3741             </s:sequence>
3742             <s:attribute name="testAttr" type="s:string" use="optional"></s:attribute>
3743             </s:complexType>
3744             </s:element>
3745            
3746             <!-- 13 -->
3747             <s:element name="sayHelloResponse">
3748             <s:complexType>
3749             <s:sequence>
3750             <s:element minOccurs="0" maxOccurs="1"
3751             name="sayHelloResult" type="s:string" />
3752             </s:sequence>
3753             </s:complexType>
3754             </s:element>
3755             </s:schema>
3756             </types>
3757            
3758             <!-- 7 -->
3759             <message name="sayHelloSoapIn">
3760             <!-- 8 -->
3761             <part name="parameters" element="s0:sayHello" />
3762             </message>
3763            
3764             <!-- 11 -->
3765             <message name="sayHelloSoapOut">
3766             <!-- 12 -->
3767             <part name="parameters" element="s0:sayHelloResponse" />
3768             </message>
3769            
3770             <portType name="Service1Soap">
3771             <operation name="sayHello">
3772             <!-- 6 -->
3773             <input message="s0:sayHelloSoapIn" />
3774             <!-- 10 -->
3775             <output message="s0:sayHelloSoapOut" />
3776             </operation>
3777             </portType>
3778            
3779             <!-- 4 -->
3780             <binding name="Service1Soap" type="s0:Service1Soap">
3781             <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
3782             style="document" />
3783            
3784             <!-- 5 -->
3785             <operation name="sayHello">
3786             <soap:operation soapAction="urn:HelloWorld#sayHello"
3787             style="document" />
3788            
3789             <input>
3790             <soap:body use="literal" />
3791             </input>
3792            
3793             <output>
3794             <soap:body use="literal" />
3795             </output>
3796             </operation>
3797             </binding>
3798            
3799             <!-- 2 -->
3800             <service name="Service1">
3801             <!-- 3 -->
3802             <port name="Service1Soap" binding="s0:Service1Soap">
3803             <soap:address
3804             location="http://localhost:81/soap-wsdl-test/helloworld.pl" />
3805             </port>
3806             </service>
3807             </definitions>
3808            
3809             You should not rely too much on this order - it may change. Even though the
3810             current order will probably remain, the nodes currently skipped might
3811             be returned somewhere along the path.
3812            
3813            
3814             =head1 LICENSE AND COPYRIGHT
3815            
3816             Copyright 2004-2008 Martin Kutter.
3817            
3818             This file is part of SOAP-WSDL. You may distribute/modify it under
3819             the same terms as perl itself
3820            
3821             =head1 AUTHOR
3822            
3823             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
3824            
3825             =head1 REPOSITORY INFORMATION
3826            
3827             $Rev: 239 $
3828             $LastChangedBy: kutterma $
3829             $Id: Client.pm 239 2007-09-11 09:45:42Z kutterma $
3830             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Client.pm $
3831            
3832             =cut
3833             SOAP_WSDL_GENERATOR_ITERATOR_WSDL11
3834              
3835 6         13 $fatpacked{"SOAP/WSDL/Generator/PrefixResolver.pm"} =
3836             <<'SOAP_WSDL_GENERATOR_PREFIXRESOLVER';
3837             package
3838             SOAP::WSDL::Generator::PrefixResolver;
3839             use strict; use warnings;
3840            
3841             use Class::Std::Fast::Storable;
3842            
3843             use version; our $VERSION = qv('2.00.99_3');
3844            
3845             my %namespace_prefix_map_of :ATTR(:name<namespace_prefix_map> :default<{}>);
3846             my %namespace_map_of :ATTR(:name<namespace_map> :default<{}>);
3847             my %prefix_of :ATTR(:name<prefix> :default<{}>);
3848            
3849             sub resolve_prefix {
3850             my ($self, $type, $namespace, $element) = @_;
3851             my $prefix;
3852             if (not defined($namespace)) {
3853             $prefix = $prefix_of{ $$self }->{ $type }
3854             }
3855             else {
3856             $prefix = $namespace_prefix_map_of{ $$self }->{ $namespace }
3857             || ( ($namespace_map_of{ $$self }->{ $namespace })
3858             ? join ('::', $prefix_of{ $$self }->{ $type }, $namespace_map_of{ $$self }->{ $namespace })
3859             : $prefix_of{ $$self }->{ $type }
3860             );
3861             }
3862             return "${prefix}::";
3863             }
3864            
3865             1;
3866            
3867             __END__
3868              
3869             SOAP_WSDL_GENERATOR_PREFIXRESOLVER
3870              
3871 6         12 $fatpacked{"SOAP/WSDL/Generator/Template.pm"} =
3872             <<'SOAP_WSDL_GENERATOR_TEMPLATE';
3873             package
3874             SOAP::WSDL::Generator::Template;
3875             use strict; use warnings;
3876             use Template 2.18;
3877             use Class::Std::Fast::Storable;
3878             use Carp;
3879             use SOAP::WSDL::Generator::PrefixResolver;
3880            
3881             use version; our $VERSION = qv('2.00.99_3');
3882            
3883             my %tt_of :ATTR(:get<tt>);
3884             my %definitions_of :ATTR(:name<definitions> :default<()>);
3885             my %server_prefix_of :ATTR(:name<server_prefix> :default<MyServer>);
3886             my %interface_prefix_of :ATTR(:name<interface_prefix> :default<MyInterfaces>);
3887             my %typemap_prefix_of :ATTR(:name<typemap_prefix> :default<MyTypemaps>);
3888             my %type_prefix_of :ATTR(:name<type_prefix> :default<MyTypes>);
3889             my %element_prefix_of :ATTR(:name<element_prefix> :default<MyElements>);
3890             my %attribute_prefix_of :ATTR(:name<attribute_prefix> :default<MyAttributes>);
3891             my %INCLUDE_PATH_of :ATTR(:name<INCLUDE_PATH> :default<()>);
3892             my %EVAL_PERL_of :ATTR(:name<EVAL_PERL> :default<0>);
3893             my %RECURSION_of :ATTR(:name<RECURSION> :default<0>);
3894             my %OUTPUT_PATH_of :ATTR(:name<OUTPUT_PATH> :default<.>);
3895            
3896             my %prefix_resolver_class_of :ATTR(:name<prefix_resolver_class> :default<SOAP::WSDL::Generator::PrefixResolver>);
3897            
3898             sub START {
3899             my ($self, $ident, $arg_ref) = @_;
3900             }
3901            
3902             sub _process :PROTECTED {
3903             my ($self, $template, $arg_ref, $output) = @_;
3904             my $ident = ident $self;
3905            
3906             # always create a new Template object to
3907             # force re-loading of plugins.
3908             my $tt = Template->new(
3909             DEBUG => 1,
3910             EVAL_PERL => $EVAL_PERL_of{ $ident },
3911             RECURSION => $RECURSION_of{ $ident },
3912             INCLUDE_PATH => $INCLUDE_PATH_of{ $ident },
3913             OUTPUT_PATH => $OUTPUT_PATH_of{ $ident },
3914             PLUGIN_BASE => 'SOAP::WSDL::Generator::Template::Plugin',
3915             )
3916             or die Template->error();
3917            
3918             $tt->process( $template,
3919             {
3920             context => {
3921             prefix_resolver_class => $prefix_resolver_class_of{ $$self },
3922             prefix_resolver => $prefix_resolver_class_of{ $$self }->new({
3923             namespace_prefix_map => {
3924             'http://www.w3.org/2001/XMLSchema' => 'SOAP::WSDL::XSD::Typelib::Builtin',
3925             },
3926             namespace_map => {
3927             },
3928             prefix => {
3929             interface => $self->get_interface_prefix,
3930             element => $self->get_element_prefix,
3931             attribute => $self->get_attribute_prefix,
3932             server => $self->get_server_prefix,
3933             type => $self->get_type_prefix,
3934             typemap => $self->get_typemap_prefix,
3935             }
3936             }),
3937             },
3938             definitions => $self->get_definitions,
3939             NO_POD => delete $arg_ref->{ NO_POD } ? 1 : 0 ,
3940             %{ $arg_ref }
3941             },
3942             $output)
3943             or croak $INCLUDE_PATH_of{ $ident }, '\\', $template, ' ', $tt->error();
3944             }
3945            
3946             1;
3947            
3948             =pod
3949            
3950             =head1 NAME
3951            
3952             SOAP::WSDL::Generator::Template - Template-based code generator
3953            
3954             =head1 DESCRIPTION
3955            
3956             SOAP::WSDL's template based code generator
3957            
3958             Base class for writing template based generators
3959            
3960             =head1 AUTHOR
3961            
3962             Replace the whitespace by @ for E-Mail Address.
3963            
3964             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
3965            
3966             =head1 LICENSE AND COPYRIGHT
3967            
3968             Copyright 2008, 2009 Martin Kutter.
3969            
3970             This file is part of SOAP-WSDL. You may distribute/modify it under
3971             the same terms as perl itself
3972            
3973             =head1 Repository information
3974            
3975             $Id: WSDLParser.pm 770 2009-01-24 22:55:54Z kutterma $
3976            
3977             $LastChangedDate: 2009-01-24 23:55:54 +0100 (Sa, 24 Jan 2009) $
3978             $LastChangedRevision: 770 $
3979             $LastChangedBy: kutterma $
3980            
3981             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/WSDLParser.pm $
3982            
3983             SOAP_WSDL_GENERATOR_TEMPLATE
3984              
3985 6         14 $fatpacked{"SOAP/WSDL/Generator/Template/Plugin/XSD.pm"} =
3986             <<'SOAP_WSDL_GENERATOR_TEMPLATE_PLUGIN_XSD';
3987             package
3988             SOAP::WSDL::Generator::Template::Plugin::XSD;
3989             use strict;
3990             use warnings;
3991             use Carp qw(confess);
3992             use Class::Std::Fast::Storable constructor => 'none';
3993             use Scalar::Util qw(blessed);
3994             use version; our $VERSION = qv('2.00.99_3');
3995            
3996             my %namespace_prefix_map_of :ATTR(:name<namespace_prefix_map> :default<{}>);
3997             my %namespace_map_of :ATTR(:name<namespace_map> :default<{}>);
3998             my %prefix_of :ATTR(:name<prefix> :default<()>);
3999             my %prefix_resolver_of :ATTR(:name<prefix_resolver> :default<()>);
4000            
4001             my %prefix_resolver_class_of :ATTR(:name<prefix_resolver_class> :default<()>);
4002            
4003             my %definitions_of :ATTR(:name<definitions> :default<()>);
4004            
4005             # create a singleton
4006             sub load { # called as MyPlugin->load($context)
4007             my ($class, $context, @arg_from) = @_;
4008             my $stash = $context->stash();
4009             my $self = bless \do { my $o = Class::Std::Fast::ID() }, $class;
4010             $self->set_prefix_resolver_class( $stash->{ context }->{ prefix_resolver_class });
4011             $self->set_prefix_resolver( $stash->{ context }->{ prefix_resolver });
4012             $self->set_definitions( $stash->{ definitions });
4013             return $self; # returns 'MyPlugin'
4014             }
4015            
4016             sub new {
4017             return shift if ref $_[0];
4018            
4019             my ($class, $arg_ref) = @_;
4020            
4021             my $self = bless \do { my $o = Class::Std::Fast::ID() }, $class;
4022             $self->set_prefix_resolver( $arg_ref->{ prefix_resolver });
4023             $self->set_definitions( $arg_ref->{ definitions });
4024             return $self; # returns 'MyPlugin'
4025             }
4026            
4027             sub _get_prefix {
4028             my ($self, $type, $node) = @_;
4029             my $namespace = defined ($node)
4030             ? ref($node)
4031             ? $node->get_targetNamespace()
4032             : $node
4033             : undef;
4034             return $self->get_prefix_resolver()->resolve_prefix(
4035             $type,
4036             $namespace,
4037             ref($node)
4038             ? $node
4039             : undef
4040             );
4041             }
4042            
4043             sub create_xsd_name {
4044             my ($self, $node) = @_;
4045             confess "no node $node" if not defined($node)
4046             or $node eq "";
4047             my $name = $self->_resolve_prefix($node) #. '::'
4048             . $node->get_name();
4049             return $self->perl_name( $name );
4050             }
4051            
4052             sub create_typemap_name {
4053             my ($self, $node) = @_;
4054             my $name = $self->_get_prefix('typemap') #. '::'
4055             . $node->get_name();
4056             return $self->perl_name( $name );
4057             }
4058            
4059             sub create_server_name {
4060             my ($self, $server, $port) = @_;
4061             my $port_name = $port->get_name();
4062             $port_name =~s{\A (?:.+)\. ([^\.]+) \z}{$1}x;
4063             my $name = join( q{},
4064             $self->_get_prefix('server', $server),
4065             join( '::', $server->get_name(), $port_name)
4066             );
4067             return $self->perl_name( $name );
4068             }
4069            
4070             sub create_interface_name {
4071             my ($self, $server, $port) = @_;
4072             my $port_name = $port->get_name();
4073             $port_name =~s{\A (?:.+)\. ([^\.]+) \z}{$1}x;
4074             my $name = join( q{},
4075             $self->_get_prefix('interface', $server),
4076             join( '::', $server->get_name(), $port_name )
4077             );
4078             return $self->perl_name( $name );
4079             }
4080            
4081             sub _resolve_prefix {
4082             my ($self, $node) = @_;
4083            
4084             if ($node->isa('SOAP::WSDL::XSD::Builtin')) {
4085             return $self->_get_prefix('type', $node)
4086             }
4087             if ( $node->isa('SOAP::WSDL::XSD::SimpleType')
4088             or $node->isa('SOAP::WSDL::XSD::ComplexType')
4089             ) {
4090             return $self->_get_prefix('type', $node);
4091             }
4092             if ( $node->isa('SOAP::WSDL::XSD::Element') ) {
4093             return $self->_get_prefix('element', $node);
4094             }
4095             if ( $node->isa('SOAP::WSDL::XSD::Attribute') ) {
4096             return $self->_get_prefix('attribute', $node);
4097             }
4098             }
4099            
4100             sub perl_name {
4101             my $self = shift;
4102             my $name = shift;
4103             $name =~s{\-}{_}xmsg;
4104             $name =~s{\.}{::}xmsg;
4105             return $name;
4106             }
4107            
4108             sub perl_var_name {
4109             my $self = shift;
4110             my $name = shift;
4111             $name =~s{\-}{_}xmsg;
4112             $name =~s{\.}{__}xmsg;
4113             return $name;
4114             }
4115            
4116             sub create_subpackage_name {
4117             my $self = shift;
4118             my $arg_ref = shift;
4119             my $type = ref $arg_ref eq 'HASH' ? $arg_ref->{ value } : $arg_ref;
4120            
4121             my @name_from = $type->get_name() || (); ;
4122            
4123             # search for top node in tree (the one directly below the Schema)
4124             my $parent = $type;
4125             my $top_node = $parent;
4126             if (! $parent->get_parent()->isa('SOAP::WSDL::XSD::Schema') ) {
4127             NAMES: while ($parent = $parent->get_parent()) {
4128             $top_node = $parent;
4129             last NAMES if $parent->get_parent()->isa('SOAP::WSDL::XSD::Schema');
4130             # skip empty names - atomic types have no name...
4131             unshift @name_from, $parent->get_name()
4132             if $parent->get_name();
4133             }
4134             }
4135             # create name for top node
4136             die "No top node found" if not defined $top_node;
4137             my $top_node_name = $self->create_xsd_name($top_node);
4138             my $package_name = join('::_', $top_node_name , (@name_from) ? join('::', @name_from) : () );
4139            
4140             # replace dots by :: in name - subpackage names may include dots, too
4141             $package_name =~s{\.}{::}xg;
4142            
4143             return $package_name;
4144             }
4145            
4146             sub create_xmlattr_name {
4147             return join '::', shift->create_subpackage_name(shift), 'XmlAttr';
4148             }
4149            
4150             sub element_name {
4151             my $self = shift;
4152             my $element = shift;
4153            
4154             confess "no element object" unless blessed $element;
4155            
4156             my $name = $element->get_name();
4157             if (! $name) {
4158             while (my $ref = $element->get_ref()) {
4159             # print "looking for: {", join('}', $element->expand( $ref )), "\n";
4160             $element = $self->get_definitions()->first_types()
4161             ->find_element($element->expand( $ref ) );
4162             # print $self->get_definitions()->first_types()->_DUMP;
4163             # for (@{$self->get_definitions()->first_types()->get_schema}) {
4164             # print $_->_DUMP;
4165             # }
4166             $name = $element->get_name();
4167             last if ($name);
4168             }
4169             }
4170             return $name;
4171             }
4172            
4173             1;
4174            
4175             =pod
4176            
4177             =head1 NAME
4178            
4179             SOAP::WSDL::Generator::Template::Plugin::XSD - Template plugin for the XSD generator
4180            
4181             =head1 METHODS
4182            
4183             =head2 perl_name
4184            
4185             XSD.perl_name(element.get_name);
4186            
4187             Converts a XML name into a valid perl name (valid for subroutines, variables
4188             or the like).
4189            
4190             perl_name takes a crude approach by just replacing . and - (dot and dash)
4191             with a underscore. This may or may not be sufficient, and may or may not
4192             provoke collisions in your XML names.
4193            
4194             =head1 LICENSE AND COPYRIGHT
4195            
4196             Copyright 2008 Martin Kutter.
4197            
4198             This file is part of SOAP-WSDL. You may distribute/modify it under the same
4199             terms as perl itself
4200            
4201             =head1 AUTHOR
4202            
4203             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
4204            
4205             =head1 REPOSITORY INFORMATION
4206            
4207             $Rev: 564 $
4208             $LastChangedBy: kutterma $
4209             $Id: ComplexType.pm 564 2008-02-23 13:31:39Z kutterma $
4210             $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm $
4211            
4212             =cut
4213            
4214             SOAP_WSDL_GENERATOR_TEMPLATE_PLUGIN_XSD
4215              
4216 6         17 $fatpacked{"SOAP/WSDL/Generator/Template/XSD.pm"} =
4217             <<'SOAP_WSDL_GENERATOR_TEMPLATE_XSD';
4218             package
4219             SOAP::WSDL::Generator::Template::XSD;
4220             use strict; use warnings;
4221             use Template 2.18;
4222             use Class::Std::Fast::Storable;
4223             use File::Basename;
4224             use File::Spec;
4225            
4226             use version; our $VERSION = qv('2.00.99_3');
4227            
4228             use SOAP::WSDL::Generator::Visitor::Typemap;
4229             use SOAP::WSDL::Generator::Template::Plugin::XSD;
4230             use base qw(SOAP::WSDL::Generator::Template);
4231            
4232             my %output_of :ATTR(:name<output> :default<()>);
4233             my %typemap_of :ATTR(:name<typemap> :default<({})>);
4234             my %use_typemap_of :ATTR(:name<use_typemap> :default<0>);
4235             my %silent_of :ATTR(:name<silent> :default<0>);
4236            
4237             sub BUILD {
4238             my ($self, $ident, $arg_ref) = @_;
4239             $self->set_EVAL_PERL(1);
4240             $self->set_RECURSION(1);
4241             $self->set_INCLUDE_PATH( exists $arg_ref->{INCLUDE_PATH}
4242             ? $arg_ref->{INCLUDE_PATH}
4243             : do {
4244             # ignore uninitialized warnings - File::Spec warns about
4245             # uninitialized values, probably because we have no filename
4246             local $SIG{__WARN__} = sub {
4247             return if ($_[0]=~m{\buninitialized\b});
4248             CORE::warn @_;
4249             };
4250            
4251             # makeup path for the OS we're running on
4252             my ($volume, $dir, $file) = File::Spec->splitpath(
4253             File::Spec->rel2abs( dirname __FILE__ )
4254             );
4255             $dir = File::Spec->catdir($dir, $file, 'XSD');
4256             # return path put together...
4257             my $path = File::Spec->catpath( $volume, $dir , q{});
4258            
4259             # Fixup path for windows - / works fine, \ does
4260             # not...
4261             if ( eval { &Win32::BuildNumber } ) {
4262             $path =~s{\\}{/}g;
4263             }
4264             $path;
4265             }
4266             );
4267             }
4268            
4269             # construct object on call to allow late binding of prefix_resolver class
4270             # and namespace maps (not used yet)
4271             sub get_name_resolver {
4272             my $self = shift;
4273             return SOAP::WSDL::Generator::Template::Plugin::XSD->new({
4274             prefix_resolver_class => $self->get_prefix_resolver_class(),
4275             prefix_resolver => $self->get_prefix_resolver_class()->new({
4276             namespace_prefix_map => {
4277             'http://www.w3.org/2001/XMLSchema' => 'SOAP::WSDL::XSD::Typelib::Builtin',
4278             },
4279             namespace_map => {
4280             },
4281             prefix => {
4282             attribute => $self->get_attribute_prefix,
4283             interface => $self->get_interface_prefix,
4284             element => $self->get_element_prefix,
4285             server => $self->get_server_prefix,
4286             type => $self->get_type_prefix,
4287             typemap => $self->get_typemap_prefix,
4288             }
4289             })
4290             });
4291             }
4292            
4293             sub generate {
4294             my $self = shift;
4295             my $opt = shift;
4296             $self->generate_typelib( $opt );
4297             $self->generate_typemap( $opt )
4298             if $self->get_use_typemap();
4299             }
4300            
4301             sub generate_typelib {
4302             my ($self, $arg_ref) = @_;
4303             my @schema = exists $arg_ref->{ schema }
4304             ? @{ $arg_ref->{schema} }
4305             : @{ $self->get_definitions()->first_types()->get_schema() };
4306             for my $type (map {
4307             @{ $_->get_type() } ,
4308             @{ $_->get_element() },
4309             @{ $_->get_attribute() }
4310             } @schema[1..$#schema] ) {
4311             $type->_accept( $self );
4312             }
4313             return;
4314             }
4315            
4316             sub _generate_interface {
4317             my $self = shift;
4318             my $arg_ref = shift;
4319             my $template_name = delete $arg_ref->{ template_name };
4320             my $name_method = delete $arg_ref->{ name_method };
4321             for my $service (@{ $self->get_definitions->get_service }) {
4322             for my $port (@{ $service->get_port() }) {
4323             # Skip ports without (known) address
4324             next if not $port->first_address;
4325             next if not $port->first_address->isa('SOAP::WSDL::SOAP::Address');
4326            
4327             my $port_name = $port->get_name;
4328             $port_name =~s{ \A .+\. }{}xms;
4329             my $output = $arg_ref->{ output }
4330             ? $arg_ref->{ output }
4331             : $self->_generate_filename(
4332             $self->get_name_resolver()->can($name_method)->(
4333             $self->get_name_resolver(),
4334             $service,
4335             $port,
4336             ));
4337             print "Creating interface class $output\n"
4338             if not $silent_of{ident $self};
4339            
4340             $self->_process($template_name,
4341             {
4342             service => $service,
4343             port => $port,
4344             NO_POD => $arg_ref->{ NO_POD } ? 1 : 0 ,
4345             USE_TYPEMAP => $self->get_use_typemap(),
4346             },
4347             $output, binmode => ':utf8');
4348             }
4349             }
4350             }
4351            
4352             sub generate_server {
4353             my ($self, $arg_ref) = @_;
4354             $arg_ref->{ template_name } = 'Server.tt';
4355             $arg_ref->{ name_method } = 'create_server_name';
4356             $self->_generate_interface($arg_ref);
4357             }
4358            
4359             sub generate_client {
4360             my ($self, $arg_ref) = @_;
4361             $arg_ref->{ template_name } = 'Interface.tt';
4362             $arg_ref->{ name_method } = 'create_interface_name';
4363             $self->_generate_interface($arg_ref);
4364             }
4365             sub generate_interface;
4366             *generate_interface = \&generate_client;
4367            
4368             sub generate_typemap {
4369             my ($self, $arg_ref) = @_;
4370            
4371             my $visitor = SOAP::WSDL::Generator::Visitor::Typemap->new({
4372             type_prefix => $self->get_type_prefix(),
4373             element_prefix => $self->get_element_prefix(),
4374             definitions => $self->get_definitions(),
4375             typemap => {
4376             'Fault' => 'SOAP::WSDL::SOAP::Typelib::Fault11',
4377             'Fault/faultcode' => 'SOAP::WSDL::XSD::Typelib::Builtin::anyURI',
4378             'Fault/faultactor' => 'SOAP::WSDL::XSD::Typelib::Builtin::token',
4379             'Fault/faultstring' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
4380             'Fault/detail' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
4381             %{ $typemap_of{ident $self }},
4382             },
4383             resolver => $self->get_name_resolver(),
4384             });
4385            
4386             use SOAP::WSDL::Generator::Iterator::WSDL11;
4387             my $iterator = SOAP::WSDL::Generator::Iterator::WSDL11->new({
4388             definitions => $self->get_definitions });
4389            
4390             for my $service (@{ $self->get_definitions->get_service }) {
4391             $iterator->init({ node => $service });
4392             while (my $node = $iterator->get_next()) {
4393             $node->_accept( $visitor );
4394             }
4395            
4396             my $output = $arg_ref->{ output }
4397             ? $arg_ref->{ output }
4398             : $self->_generate_filename( $self->get_name_resolver()->create_typemap_name($service) );
4399             print "Creating typemap class $output\n"
4400             if not $silent_of{ident $self};
4401             $self->_process('Typemap.tt',
4402             {
4403             service => $service,
4404             typemap => $visitor->get_typemap(),
4405             NO_POD => $arg_ref->{ NO_POD } ? 1 : 0 ,
4406             },
4407             $output);
4408             }
4409             }
4410            
4411             sub _generate_filename :PRIVATE {
4412             my ($self, $name) = @_;
4413             $name =~s{ \. }{::}xmsg;
4414             $name =~s{ \- }{_}xmsg;
4415             $name =~s{ :: }{/}xmsg;
4416             return "$name.pm";
4417             }
4418            
4419             sub visit_XSD_Attribute {
4420             my ($self, $attribute) = @_;
4421             my $output = defined $output_of{ ident $self }
4422             ? $output_of{ ident $self }
4423             : $self->_generate_filename( $self->get_name_resolver()->create_xsd_name($attribute) );
4424             $self->_process('attribute.tt', { attribute => $attribute } , $output);
4425             }
4426            
4427             sub visit_XSD_Element {
4428             my ($self, $element) = @_;
4429             my $output = defined $output_of{ ident $self }
4430             ? $output_of{ ident $self }
4431             : $self->_generate_filename( $self->get_name_resolver()->create_xsd_name($element) );
4432             warn "Creating element class $output \n"
4433             if not $silent_of{ ident $self};
4434             $self->_process('element.tt', { element => $element } , $output);
4435             }
4436            
4437             sub visit_XSD_SimpleType {
4438             my ($self, $type) = @_;
4439             my $output = defined $output_of{ ident $self }
4440             ? $output_of{ ident $self }
4441             : $self->_generate_filename( $self->get_name_resolver()->create_xsd_name($type) );
4442             warn "Creating simpleType class $output \n"
4443             if not $silent_of{ ident $self};
4444             $self->_process('simpleType.tt', { simpleType => $type } , $output);
4445             }
4446            
4447             sub visit_XSD_ComplexType {
4448             my ($self, $type) = @_;
4449             my $output = defined $output_of{ ident $self }
4450             ? $output_of{ ident $self }
4451             : $self->_generate_filename( $self->get_name_resolver()->create_xsd_name($type) );
4452             warn "Creating complexType class $output \n"
4453             if not $silent_of{ ident $self};
4454             $self->_process('complexType.tt', { complexType => $type } , $output);
4455             }
4456            
4457             1;
4458            
4459             =pod
4460            
4461             =head1 NAME
4462            
4463             SOAP::WSDL::Generator::Template::XSD - XSD code generator
4464            
4465             =head1 DESCRIPTION
4466            
4467             SOAP::WSDL's XSD code generator
4468            
4469             =head1 SYNOPSIS
4470            
4471             See L<wsdl2perl.pl|wsdl2perl.pl> for an example on how to use this class.
4472            
4473             =head1 METHODS
4474            
4475             =head2 new
4476            
4477             Constructor.
4478            
4479             Options (Options can also be set via set_OPTION methods):
4480            
4481             =over
4482            
4483             =item * silent
4484            
4485             Suppress warnings about what's being generated
4486            
4487             =back
4488            
4489             =head2 generate
4490            
4491             Shortcut for calling L<generate_typelib> and L<generate_client>
4492            
4493             =head2 generate_client
4494            
4495             Generates a client interface
4496            
4497             =head2 generate_server
4498            
4499             Generates a server class
4500            
4501             =head2 generate_typelib
4502            
4503             Generates type and element classes
4504            
4505             =head2 generate_typemap
4506            
4507             Generate a typemap class required by SOAP::WSDL's MessageParser
4508            
4509             =head2 generate_interface
4510            
4511             (Deprecated) alias for generate_client
4512            
4513             =head2 get_name_resolver
4514            
4515             Returns a name resolver template plugin
4516            
4517             =head2 visit_XSD_Attribute
4518            
4519             Visitor method for SOAP::WSDL::XSD::Attribute. Should be factored out into
4520             visitor class.
4521            
4522             =head2 visit_XSD_ComplexType
4523            
4524             Visitor method for SOAP::WSDL::XSD::ComplexType. Should be factored out into
4525             visitor class.
4526            
4527             =head2 visit_XSD_Element
4528            
4529             Visitor method for SOAP::WSDL::XSD::Element. Should be factored out into
4530             visitor class.
4531            
4532             =head2 visit_XSD_SimpleType
4533            
4534             Visitor method for SOAP::WSDL::XSD::SimpleType. Should be factored out into
4535             visitor class.
4536            
4537             =head1 AUTHOR
4538            
4539             Replace the whitespace by @ for E-Mail Address.
4540            
4541             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
4542            
4543             =head1 LICENSE AND COPYRIGHT
4544            
4545             Copyright 2008, 2009 Martin Kutter.
4546            
4547             This file is part of SOAP-WSDL. You may distribute/modify it under
4548             the same terms as perl itself
4549            
4550             =head1 Repository information
4551            
4552             $Id: WSDLParser.pm 770 2009-01-24 22:55:54Z kutterma $
4553            
4554             $LastChangedDate: 2009-01-24 23:55:54 +0100 (Sa, 24 Jan 2009) $
4555             $LastChangedRevision: 770 $
4556             $LastChangedBy: kutterma $
4557            
4558             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/WSDLParser.pm $
4559            
4560             SOAP_WSDL_GENERATOR_TEMPLATE_XSD
4561              
4562 6         16 $fatpacked{"SOAP/WSDL/Generator/Visitor.pm"} =
4563             <<'SOAP_WSDL_GENERATOR_VISITOR';
4564             package
4565             SOAP::WSDL::Generator::Visitor;
4566             use strict;
4567             use warnings;
4568             use Class::Std::Fast::Storable;
4569            
4570             use version; our $VERSION = qv('2.00.99_3');
4571            
4572             my %definitions_of :ATTR(:name<definitions> :default<()>);
4573             my %type_prefix_of :ATTR(:name<type_prefix> :default<()>);
4574             my %element_prefix_of :ATTR(:name<element_prefix> :default<()>);
4575            
4576             sub START {
4577             my ($self, $ident, $arg_ref) = @_;
4578             $type_prefix_of{ $ident } = 'MyType' if not exists
4579             $arg_ref->{ 'type_prefix' };
4580             $element_prefix_of{ $ident } = 'MyElement' if not exists
4581             $arg_ref->{ 'element_prefix' };
4582            
4583             }
4584            
4585            
4586             # WSDL stuff
4587             sub visit_Definitions {}
4588             sub visit_Binding {}
4589             sub visit_Message {}
4590             sub visit_Operation {}
4591             sub visit_OpMessage {}
4592             sub visit_Part {}
4593             sub visit_Port {}
4594             sub visit_PortType {}
4595             sub visit_Service {}
4596             sub visit_SoapOperation {}
4597             sub visit_Types {}
4598            
4599             # XML Schema stuff
4600             sub visit_XSD_Schema {}
4601             sub visit_XSD_ComplexType {}
4602             sub visit_XSD_Element {}
4603             sub visit_XSD_SimpleType {}
4604            
4605             1;
4606            
4607             __END__
4608            
4609              
4610             SOAP_WSDL_GENERATOR_VISITOR
4611              
4612 6         42 $fatpacked{"SOAP/WSDL/Generator/Visitor/Typemap.pm"} =
4613             <<'SOAP_WSDL_GENERATOR_VISITOR_TYPEMAP';
4614             package
4615             SOAP::WSDL::Generator::Visitor::Typemap;
4616             use strict;
4617             use warnings;
4618             use Class::Std::Fast::Storable;
4619            
4620             use base qw(SOAP::WSDL::Generator::Visitor);
4621            
4622             use version; our $VERSION = qv('2.00.99_3');
4623            
4624             my %path_of :ATTR(:name<path> :default<[]>);
4625             my %typemap_of :ATTR(:name<typemap> :default<()>);
4626             my %resolver_of :ATTR(:name<resolver> :default<()>);
4627            
4628             sub START {
4629             my ($self, $ident, $arg_ref) = @_;
4630             $resolver_of { $ident } = $arg_ref->{ resolver };
4631             }
4632            
4633             sub set_typemap_entry {
4634             my ($self, $value) = @_;
4635             # warn join( q{/}, @{ $path_of{ ident $self } }) . " => $value";
4636             $typemap_of{ ident $self }->{
4637             join( q{/}, @{ $path_of{ ident $self } } )
4638             } = $value;
4639             }
4640            
4641             sub add_element_path {
4642             my ($self, $element) = @_;
4643            
4644             # Swapping out this lines against the ones below generates
4645             # a namespace-sensitive typemap.
4646             # Well almost: Class names are not constructed in a namespace-sensitive
4647             # manner, yet - there should be some facility to allow binding a (perl)
4648             # prefix to a namespace...
4649            
4650             if (my $ref = $element->get_ref() ) {
4651             $element = $self->get_definitions()->first_types()->find_element(
4652             $element->expand($ref) );
4653             }
4654             my $name = $element->get_name();
4655            
4656             push @{ $path_of{ ident $self } }, $name;
4657             }
4658            
4659             sub process_referenced_type {
4660             my ( $self, $ns, $localname ) = @_;
4661            
4662             my $ident = ident $self;
4663            
4664             # get type's class name
4665             # Caveat: visits type if it's a referenced type from the
4666             # a ? b : c operation.
4667             my ($type, $typeclass);
4668             $type = $self->get_definitions()->first_types()->find_type( $ns, $localname );
4669             $typeclass = $self->get_resolver()->create_xsd_name($type);
4670            
4671             # set before to allow it to be used from inside _accept
4672             $self->set_typemap_entry($typeclass);
4673            
4674             $type->_accept($self) if ($ns ne 'http://www.w3.org/2001/XMLSchema');
4675            
4676             # set afterwards again (just to be sure...)
4677             $self->set_typemap_entry($typeclass);
4678             return $self;
4679             }
4680            
4681             sub visit_XSD_Element {
4682             my ( $self, $ident, $element ) = ( $_[0], ident $_[0], $_[1] );
4683            
4684             # warn "simpleType " . $element->get_name();
4685             my @path = @{ $path_of{ ${ $self } } };
4686             my $path = join '/', @path;
4687             my $parent = $typemap_of{ ${ $self } }->{ $path };
4688            
4689             # step down in tree
4690             $self->add_element_path( $element );
4691            
4692             # now call all possible variants.
4693             # They all just return if no argument is given,
4694             # and return $self on success.
4695             SWITCH: {
4696             my $name = $element->get_name();
4697            
4698             if ($element->get_type) {
4699             $self->process_referenced_type( $element->expand( $element->get_type() ) );
4700             last SWITCH;
4701             }
4702            
4703             # atomic simpleType typemap rule:
4704             # if we have a parent, use parent's sub-package.
4705             # if not, use element package.
4706             if ($element->get_simpleType()) {
4707             # warn "simpleType " . $element->get_name();
4708             my @path = @{ $path_of{ ${ $self } } };
4709             my $typeclass = $self->get_resolver()->create_subpackage_name($element);
4710             $self->set_typemap_entry($typeclass);
4711             $typeclass =~s{\.}{::}g;
4712             $typeclass =~s{\-}{_}g;
4713             last SWITCH;
4714             }
4715            
4716             # for atomic and complex types , and ref elements
4717             my $typeclass = $self->get_resolver()->create_subpackage_name($element);
4718             $self->set_typemap_entry($typeclass);
4719            
4720             if (my $complexType = $element->first_complexType()) {
4721             $complexType->_accept($self);
4722             last SWITCH;
4723             }
4724            
4725             # element ref handling
4726             if (my $ref = $element->get_ref()) {
4727             $element = $self->get_definitions()->first_types()->find_element(
4728             $element->expand($ref) );
4729             # we added a path too much - we should add the path of this
4730             # element instead.
4731             pop @{ $path_of{$ident} };
4732             $element->_accept($self);
4733             # and we must not pop it off now - thus, just return
4734             return;
4735             }
4736             die "Neither type nor ref in element >". $element->get_name ."<. Don't know what to do."
4737             };
4738            
4739             # Safety measure. If someone defines a top-level element with
4740             # a normal (not atomic) type, we just override it here
4741             if (not defined($parent)) {
4742             # for atomic and complex types , and ref elements
4743             my $typeclass = $self->get_resolver()->create_xsd_name($element);
4744             $self->set_typemap_entry($typeclass);
4745             }
4746            
4747             # step up in hierarchy
4748             pop @{ $path_of{$ident} };
4749             }
4750            
4751             sub visit_XSD_ComplexType {
4752             my ($self, $ident, $type) = ($_[0], ident $_[0], $_[1] );
4753             my $variety = $type->get_variety();
4754             my $derivation = $type->get_derivation();
4755             my $content_model = $type->get_contentModel;
4756             return if not $variety; # empty complexType
4757             return if ($content_model eq 'simpleContent');
4758            
4759             if ( grep { $_ eq $variety} qw(all sequence choice) )
4760             {
4761             # visit child elements
4762             for (@{ $type->get_element() || [] }) {
4763             $_->_accept( $self );
4764             }
4765             }
4766             # Only continue for derived types
4767             # Saves a uninitialized warning.
4768             return if not $derivation;
4769            
4770             if ($derivation eq 'restriction' ) {
4771             # TODO check and probably correct - this includes
4772             # all base type's elements in a restriction derivation.
4773             # Probably wrong.
4774             #
4775             # resolve base / get atomic type and run on elements
4776             if (my $type_name = $type->get_base()) {
4777             my $subtype = $self->get_definitions()
4778             ->first_types()->find_type( $type->expand($type_name) );
4779             # visit child elements
4780             for (@{ $subtype->get_element() || [] }) {
4781             $_->_accept( $self );
4782             }
4783             }
4784             }
4785             elsif ($derivation eq 'extension' ) {
4786             # resolve base / get atomic type and run on elements
4787             while (my $type_name = $type->get_base()) {
4788             $type = $self->get_definitions()
4789             ->first_types()->find_type( $type->expand($type_name) );
4790             # visit child elements
4791             for (@{ $type->get_element() || [] }) {
4792             $_->_accept( $self );
4793             }
4794             }
4795             }
4796             }
4797            
4798             1;
4799            
4800             __END__
4801            
4802             =pod
4803            
4804             =head1 NAME
4805            
4806             SOAP::WSDL::Generator::Visitor::Typemap - Visitor class for generating typemaps
4807            
4808             =head1 DESCRIPTION
4809            
4810             Visitor used by SOAP::WSDL's XSD generator for creating typemaps
4811            
4812             =head1 AUTHOR
4813            
4814             Replace the whitespace by @ for E-Mail Address.
4815            
4816             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
4817            
4818             =head1 LICENSE AND COPYRIGHT
4819            
4820             Copyright 2008, 2009 Martin Kutter.
4821            
4822             This file is part of SOAP-WSDL. You may distribute/modify it under
4823             the same terms as perl itself
4824            
4825             =head1 Repository information
4826            
4827             $Id: WSDLParser.pm 770 2009-01-24 22:55:54Z kutterma $
4828            
4829             $LastChangedDate: 2009-01-24 23:55:54 +0100 (Sa, 24 Jan 2009) $
4830             $LastChangedRevision: 770 $
4831             $LastChangedBy: kutterma $
4832            
4833             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/WSDLParser.pm $
4834            
4835             SOAP_WSDL_GENERATOR_VISITOR_TYPEMAP
4836              
4837 6         25 $fatpacked{"SOAP/WSDL/Message.pm"} = <<'SOAP_WSDL_MESSAGE';
4838             package
4839             SOAP::WSDL::Message;
4840             use strict;
4841             use warnings;
4842             use Class::Std::Fast::Storable;
4843             use base qw(SOAP::WSDL::Base);
4844            
4845             use version; our $VERSION = qv('2.00.99_3');
4846            
4847             my %part_of :ATTR(:name<part> :default<[]>);
4848            
4849             1;
4850             SOAP_WSDL_MESSAGE
4851              
4852 6         12 $fatpacked{"SOAP/WSDL/OpMessage.pm"} = <<'SOAP_WSDL_OPMESSAGE';
4853             package
4854             SOAP::WSDL::OpMessage;
4855             use strict;
4856             use warnings;
4857             use Class::Std::Fast::Storable;
4858             use base qw(SOAP::WSDL::Base);
4859            
4860             use version; our $VERSION = qv('2.00.99_3');
4861            
4862             my %body_of :ATTR(:name<body> :default<[]>);
4863             my %header_of :ATTR(:name<header> :default<[]>);
4864             my %headerfault_of :ATTR(:name<headerfault> :default<[]>);
4865             my %message_of :ATTR(:name<message> :default<()>);
4866            
4867             1;
4868             SOAP_WSDL_OPMESSAGE
4869              
4870 6         14 $fatpacked{"SOAP/WSDL/Operation.pm"} = <<'SOAP_WSDL_OPERATION';
4871             package
4872             SOAP::WSDL::Operation;
4873             use strict;
4874             use warnings;
4875             use Class::Std::Fast::Storable;
4876             use base qw(SOAP::WSDL::Base);
4877            
4878             use version; our $VERSION = qv('2.00.99_3');
4879            
4880             my %operation_of :ATTR(:name<operation> :default<()>);
4881             my %input_of :ATTR(:name<input> :default<[]>);
4882             my %output_of :ATTR(:name<output> :default<[]>);
4883             my %fault_of :ATTR(:name<fault> :default<[]>);
4884             my %type_of :ATTR(:name<type> :default<()>);
4885             my %style_of :ATTR(:name<style> :default<()>);
4886             my %transport_of :ATTR(:name<transport> :default<()>);
4887             my %parameterOrder_of :ATTR(:name<parameterOrder> :default<()>);
4888            
4889             1;
4890             SOAP_WSDL_OPERATION
4891              
4892 6         23 $fatpacked{"SOAP/WSDL/Part.pm"} = <<'SOAP_WSDL_PART';
4893             package
4894             SOAP::WSDL::Part;
4895             use strict;
4896             use warnings;
4897             use Carp qw(croak);
4898             use Class::Std::Fast::Storable;
4899            
4900             use base qw(SOAP::WSDL::Base);
4901            
4902             use version; our $VERSION = qv('2.00.99_3');
4903            
4904             my %element_of :ATTR(:name<element> :default<()>);
4905             my %type_of :ATTR(:name<type> :default<()>);
4906            
4907             sub serialize
4908             {
4909             my $self = shift;
4910             my $name = shift;
4911             my $data = shift;
4912             my $opt = shift;
4913             my $typelib = $opt->{ typelib } || die "No typelib";
4914             my %ns_map = %{ $opt->{ namespace } };
4915            
4916             my $item_name;
4917             if ($item_name = $self->get_type() ) {
4918             # resolve type
4919             my ($prefix, $localname) = split /:/ , $item_name, 2;
4920             my $type = $typelib->find_type( $ns_map{ $prefix }, $localname)
4921             or die "type $item_name , $ns_map{ $prefix } not found";
4922            
4923             my $name = $self->get_name();
4924             return $type->serialize( $name, $data->{ $name }, $opt );
4925             }
4926             elsif ( $item_name = $self->get_element() ) {
4927             my ($prefix, $localname) = split /:/ , $item_name, 2;
4928             my $element = $typelib->find_element(
4929             $ns_map{ $prefix },
4930             $localname
4931             )
4932             or die "element $item_name , $ns_map{ $prefix } not found";
4933             $opt->{ qualify } = 1;
4934             return $element->serialize( undef, $data->{ $element->get_name() }, $opt );
4935             }
4936             die "Neither type nor element - don't know what to do";
4937             }
4938            
4939             1;
4940             SOAP_WSDL_PART
4941              
4942 6         14 $fatpacked{"SOAP/WSDL/Port.pm"} = <<'SOAP_WSDL_PORT';
4943             package
4944             SOAP::WSDL::Port;
4945             use strict;
4946             use warnings;
4947             use Class::Std::Fast::Storable;
4948             use base qw(SOAP::WSDL::Base);
4949            
4950             use version; our $VERSION = qv('2.00.99_3');
4951            
4952             my %binding_of :ATTR(:name<binding> :default<()>);
4953             my %address_of :ATTR(:name<address> :default<()>);
4954            
4955             1;
4956             SOAP_WSDL_PORT
4957              
4958 6         15 $fatpacked{"SOAP/WSDL/PortType.pm"} = <<'SOAP_WSDL_PORTTYPE';
4959             package
4960             SOAP::WSDL::PortType;
4961             use strict;
4962             use warnings;
4963             use Class::Std::Fast::Storable;
4964             use List::Util;
4965             use base qw(SOAP::WSDL::Base);
4966            
4967             use version; our $VERSION = qv('2.00.99_3');
4968            
4969             my %operation_of :ATTR(:name<operation> :default<()>);
4970            
4971             #
4972             #=head2 find_operation
4973             #
4974             #$port_type->find_operation($namespace, $name)
4975             #
4976             #Returns the PortType's operation object matching the given namespace and
4977             #name
4978             #
4979            
4980             sub find_operation {
4981             return List::Util::first {
4982             ( $_->get_targetNamespace() eq $_[1] ) && ( $_->get_name() eq $_[2] )
4983             } @{ $operation_of{ ${ $_[0] } } };
4984             };
4985            
4986             1;
4987             SOAP_WSDL_PORTTYPE
4988              
4989 6         13 $fatpacked{"SOAP/WSDL/SOAP/Address.pm"} = <<'SOAP_WSDL_SOAP_ADDRESS';
4990             package
4991             SOAP::WSDL::SOAP::Address;
4992             use strict;
4993             use warnings;
4994             use base qw(SOAP::WSDL::Base);
4995             use Class::Std::Fast::Storable;
4996            
4997             use version; our $VERSION = qv('2.00.99_3');
4998            
4999             my %location :ATTR(:name<location> :default<()>);
5000             1;
5001             SOAP_WSDL_SOAP_ADDRESS
5002              
5003 6         12 $fatpacked{"SOAP/WSDL/SOAP/Body.pm"} = <<'SOAP_WSDL_SOAP_BODY';
5004             package
5005             SOAP::WSDL::SOAP::Body;
5006             use strict;
5007             use warnings;
5008             use base qw(SOAP::WSDL::Base);
5009             use Class::Std::Fast::Storable;
5010            
5011             use version; our $VERSION = qv('2.00.99_3');
5012            
5013             my %use_of :ATTR(:name<use> :default<q{}>);
5014             my %namespace_of :ATTR(:name<namespace> :default<q{}>);
5015             my %encodingStyle_of :ATTR(:name<encodingStyle> :default<q{}>);
5016             my %parts_of :ATTR(:name<parts> :default<q{}>);
5017            
5018             1;
5019             SOAP_WSDL_SOAP_BODY
5020              
5021 6         15 $fatpacked{"SOAP/WSDL/SOAP/Header.pm"} = <<'SOAP_WSDL_SOAP_HEADER';
5022             package
5023             SOAP::WSDL::SOAP::Header;
5024             use strict;
5025             use warnings;
5026             use base qw(SOAP::WSDL::Base);
5027             use Class::Std::Fast::Storable;
5028            
5029             use version; our $VERSION = qv('2.00.99_3');
5030            
5031             my %use_of :ATTR(:name<use> :default<q{}>);
5032             my %namespace_of :ATTR(:name<namespace> :default<q{}>);
5033             my %encodingStyle_of :ATTR(:name<encodingStyle> :default<q{}>);
5034             my %message_of :ATTR(:name<message> :default<()>);
5035             my %part_of :ATTR(:name<part> :default<q{}>);
5036            
5037            
5038             1;
5039             SOAP_WSDL_SOAP_HEADER
5040              
5041 6         14 $fatpacked{"SOAP/WSDL/SOAP/HeaderFault.pm"} =
5042             <<'SOAP_WSDL_SOAP_HEADERFAULT';
5043             package
5044             SOAP::WSDL::SOAP::HeaderFault;
5045             use strict;
5046             use warnings;
5047             use base qw(SOAP::WSDL::Header);
5048            
5049             use version; our $VERSION = qv('2.00.99_3');
5050            
5051             1;
5052             SOAP_WSDL_SOAP_HEADERFAULT
5053              
5054 6         14 $fatpacked{"SOAP/WSDL/SOAP/Operation.pm"} = <<'SOAP_WSDL_SOAP_OPERATION';
5055             package
5056             SOAP::WSDL::SOAP::Operation;
5057             use strict;
5058             use warnings;
5059             use Class::Std::Fast::Storable;
5060             use base qw(SOAP::WSDL::Base);
5061            
5062             use version; our $VERSION = qv('2.00.99_3');
5063            
5064             my %style_of :ATTR(:name<style> :default<()>);
5065             my %soapAction_of :ATTR(:name<soapAction> :default<()>);
5066            
5067             1;
5068             SOAP_WSDL_SOAP_OPERATION
5069              
5070 6         16 $fatpacked{"SOAP/WSDL/SOAP/Typelib/Fault.pm"} =
5071             <<'SOAP_WSDL_SOAP_TYPELIB_FAULT';
5072             package
5073             SOAP::WSDL::SOAP::Typelib::Fault;
5074             use strict;
5075             use warnings;
5076             use Class::Std::Fast::Storable constructor => 'none';
5077            
5078             use version; our $VERSION = qv('2.00.99_3');
5079            
5080             1;
5081             SOAP_WSDL_SOAP_TYPELIB_FAULT
5082              
5083 6         14 $fatpacked{"SOAP/WSDL/SOAP/Typelib/Fault11.pm"} =
5084             <<'SOAP_WSDL_SOAP_TYPELIB_FAULT11';
5085             package
5086             SOAP::WSDL::SOAP::Typelib::Fault11;
5087             {
5088             use strict;
5089             use warnings;
5090             use Class::Std::Fast::Storable constructor => 'none';
5091            
5092             use version; our $VERSION = qv('2.00.99_3');
5093            
5094             use Scalar::Util qw(blessed);
5095            
5096             use SOAP::WSDL::XSD::Typelib::ComplexType;
5097             use SOAP::WSDL::XSD::Typelib::Element;
5098            
5099             use base qw(
5100             SOAP::WSDL::SOAP::Typelib::Fault
5101             SOAP::WSDL::XSD::Typelib::Element
5102             SOAP::WSDL::XSD::Typelib::ComplexType
5103             );
5104            
5105             my %faultcode_of : ATTR(:get<faultcode>);
5106             my %faultstring_of : ATTR(:get<faultstring>);
5107             my %faultactor_of : ATTR(:get<faultactor>);
5108             my %detail_of : ATTR(:get<detail>);
5109            
5110             __PACKAGE__->_factory(
5111             [qw(faultcode faultstring faultactor detail)],
5112             {
5113             faultcode => \%faultcode_of,
5114             faultstring => \%faultstring_of,
5115             faultactor => \%faultactor_of,
5116             detail => \%detail_of,
5117             },
5118             {
5119             faultcode => 'SOAP::WSDL::XSD::Typelib::Builtin::QName',
5120             faultstring => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
5121             faultactor => 'SOAP::WSDL::XSD::Typelib::Builtin::anyURI',
5122             detail => 'SOAP::WSDL::SOAP::Typelib::Fault11Detail',
5123             } );
5124            
5125             sub get_xmlns { return 'http://schemas.xmlsoap.org/soap/envelope/' }
5126            
5127             __PACKAGE__->__set_name('Fault');
5128             __PACKAGE__->__set_nillable(0);
5129             __PACKAGE__->__set_minOccurs();
5130             __PACKAGE__->__set_maxOccurs();
5131             __PACKAGE__->__set_ref('');
5132            
5133             # always return false in boolean context - a fault is never true...
5134             sub as_bool : BOOLIFY {
5135             return;
5136             }
5137            
5138             # override set_detail to allow "auto-vivification" of a details object
5139             # must be implemented via symbol table operation - _factory adds
5140             # methods via symbol table, too.
5141            
5142             # BLOCK to scope warnings
5143             {
5144             no warnings qw(redefine);
5145             my $set_detail_sub = \&set_detail;
5146             *set_detail = sub {
5147             my ( $self, $detail ) = @_;
5148            
5149             # create SOAP::WSDL::SOAP::Typelib::Fault11Detail wrapper if there
5150             # is none
5151             if ( not blessed $detail
5152             or
5153             not $detail->isa('SOAP::WSDL::SOAP::Typelib::Fault11Detail') )
5154             {
5155             $detail = SOAP::WSDL::SOAP::Typelib::Fault11Detail->new(
5156             {value => $detail} );
5157             }
5158            
5159             # call original method
5160             $set_detail_sub->( $self, $detail );
5161             };
5162             }
5163             Class::Std::initialize();
5164             }
5165            
5166             package
5167             SOAP::WSDL::SOAP::Typelib::Fault11Detail;
5168             {
5169             use strict;
5170             use warnings;
5171             use Class::Std::Fast::Storable constructor => 'none';
5172             use base qw(
5173             SOAP::WSDL::XSD::Typelib::Element
5174             SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType
5175             );
5176            
5177             sub get_xmlns { return 'http://schemas.xmlsoap.org/soap/envelope/' }
5178            
5179             __PACKAGE__->__set_name('Fault');
5180             __PACKAGE__->__set_nillable(0);
5181             __PACKAGE__->__set_minOccurs();
5182             __PACKAGE__->__set_maxOccurs();
5183             Class::Std::initialize();
5184             }
5185            
5186             1;
5187            
5188             =pod
5189            
5190             =head1 NAME
5191            
5192             SOAP::WSDL::SOAP::Typelib::Fault11 - SOAP 1.1 Fault class
5193            
5194             =head1 DESCRIPTION
5195            
5196             Models a SOAP 1.1 Fault.
5197            
5198             SOAP::WSDL::SOAP::Typelib::Fault11 objects are false in boolean context
5199             and serialize to XML on stringification.
5200            
5201             This means you can do something like:
5202            
5203             my $soap = SOAP::WSDL::Client->new();
5204             # ...
5205             my $result = $soap->call($method, $data);
5206             if (not $result) {
5207             die "Error calling SOAP method: ", $result->get_faultstring();
5208             }
5209            
5210             =head1 METHODS
5211            
5212             =head2 get_faultcode / set_faultcode
5213            
5214             Getter/setter for object's faultcode property.
5215            
5216             =head2 get_faultstring / set_faultstring
5217            
5218             Getter/setter for object's faultstring property.
5219            
5220             =head2 get_faultactor / set_faultactor
5221            
5222             Getter/setter for object's faultactor property.
5223            
5224             =head2 get_detail / set_detail
5225            
5226             Getter/setter for detail object's detail property.
5227            
5228             The detail element is a SOAP::WSDL::SOAP::Typelib::Fault11Detail object.
5229             This class is automatically loaded when using
5230             SOAP::WSDL::SOAP::Typelib::Fault11, so you can't B<use> it separately.
5231            
5232             Any string or object not of this class will be automatically wrapped into
5233             a detail object.
5234            
5235             Note that passing a list of detail object is currently not supported (though
5236             the SOAP1.1 note allows this).
5237            
5238             =head1 LICENSE AND COPYRIGHT
5239            
5240             Copyright 2007 Martin Kutter. All rights reserved.
5241            
5242             This file is part of SOAP-WSDL. You may distribute/modify it under
5243             the same terms as perl itself
5244            
5245             =head1 AUTHOR
5246            
5247             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
5248            
5249             =head1 REPOSITORY INFORMATION
5250            
5251             $Rev: 861 $
5252             $LastChangedBy: kutterma $
5253             $Id: Fault11.pm 861 2010-03-28 10:41:26Z kutterma $
5254             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/SOAP/Typelib/Fault11.pm $
5255            
5256             =cut
5257            
5258             SOAP_WSDL_SOAP_TYPELIB_FAULT11
5259              
5260 6         12 $fatpacked{"SOAP/WSDL/Serializer/XSD.pm"} = <<'SOAP_WSDL_SERIALIZER_XSD';
5261             #!/usr/bin/perl -w
5262             package
5263             SOAP::WSDL::Serializer::XSD;
5264             use strict;
5265             use warnings;
5266             use Class::Std::Fast::Storable;
5267             use Scalar::Util qw(blessed);
5268            
5269             use version; our $VERSION = qv('2.00.99_3');
5270            
5271             use SOAP::WSDL::Factory::Serializer;
5272            
5273             my $SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/';
5274             my $XML_INSTANCE_NS = 'http://www.w3.org/2001/XMLSchema-instance';
5275             my $XML_SCHEMA_NS = 'http://www.w3.org/2001/XMLSchema';
5276            
5277             sub serialize {
5278             my ($self, $args_of_ref) = @_;
5279            
5280             my $opt = $args_of_ref->{ options };
5281            
5282             if (not $opt->{ namespace }->{ $SOAP_NS })
5283             {
5284             $opt->{ namespace }->{ $SOAP_NS } = 'SOAP-ENV';
5285             }
5286            
5287             if (not $opt->{ namespace }->{ $XML_INSTANCE_NS })
5288             {
5289             $opt->{ namespace }->{ $XML_INSTANCE_NS } = 'xsi';
5290             }
5291            
5292             if (not $opt->{ namespace }->{ $XML_SCHEMA_NS })
5293             {
5294             $opt->{ namespace }->{ $XML_SCHEMA_NS } = 'xs';
5295             }
5296             my $soap_prefix = $opt->{ namespace }->{ $SOAP_NS };
5297            
5298             # envelope start with namespaces
5299             my $xml = "<$soap_prefix\:Envelope ";
5300            
5301             while (my ($uri, $prefix) = each %{ $opt->{ namespace } })
5302             {
5303             $xml .= "xmlns:$prefix=\"$uri\" ";
5304             }
5305             #
5306             # add namespace for user-supplied prefix if needed
5307             $xml .= "xmlns:$opt->{prefix}=\"" . $args_of_ref->{ body }->get_xmlns() . "\" "
5308             if $opt->{prefix};
5309            
5310             # TODO insert encoding
5311             $xml.='>';
5312             $xml .= $self->serialize_header($args_of_ref->{ method }, $args_of_ref->{ header }, $opt);
5313             $xml .= $self->serialize_body($args_of_ref->{ method }, $args_of_ref->{ body }, $opt);
5314             $xml .= '</' . $soap_prefix .':Envelope>';
5315             return $xml;
5316             }
5317            
5318             sub serialize_header {
5319             my ($self, $method, $data, $opt) = @_;
5320            
5321             # header is optional. Leave out if there's no header data
5322             return q{} if not $data;
5323             return join ( q{},
5324             "<$opt->{ namespace }->{ $SOAP_NS }\:Header>",
5325             blessed $data ? $data->serialize_qualified : (),
5326             "</$opt->{ namespace }->{ $SOAP_NS }\:Header>",
5327             );
5328             }
5329            
5330             sub serialize_body {
5331             my ($self, $method, $data, $opt) = @_;
5332            
5333             # TODO This one wipes out the old class' XML name globally
5334             # Fix in some more appropriate place...
5335             $data->__set_name("$opt->{prefix}:" . $data->__get_name() ) if $opt->{prefix};
5336            
5337             # Body is NOT optional. Serialize to empty body
5338             # if we have no data.
5339             return join ( q{},
5340             "<$opt->{ namespace }->{ $SOAP_NS }\:Body>",
5341             defined $data
5342             ? ref $data eq 'ARRAY'
5343             ? join q{}, map { blessed $_ ? $_->serialize_qualified() : () } @{ $data }
5344             : blessed $data
5345             ? $opt->{prefix}
5346             ? $data->serialize()
5347             : $data->serialize_qualified()
5348             : ()
5349             : (),
5350             "</$opt->{ namespace }->{ $SOAP_NS }\:Body>",
5351             );
5352             }
5353            
5354             __END__
5355            
5356             =pod
5357            
5358             =head1 NAME
5359            
5360             SOAP:WSDL::Serializer::XSD - Serializer for SOAP::WSDL::XSD::Typelib:: objects
5361            
5362             =head1 DESCRIPTION
5363            
5364             This is the default serializer for SOAP::WSDL::Client and Interface classes
5365             generated by SOAP::WSDL
5366            
5367             It may be used as a template for creating custom serializers.
5368            
5369             See L<SOAP::WSDL::Factory::Serializer|SOAP::WSDL::Factory::Serializer> for
5370             details on that.
5371            
5372             =head1 METHODS
5373            
5374             =head2 serialize
5375            
5376             Creates a SOAP envelope based on the body and header arguments passed.
5377            
5378             Sets SOAP namespaces.
5379            
5380             =head2 serialize_body
5381            
5382             Serializes a message body to XML
5383            
5384             =head2 serialize_header
5385            
5386             Serializes a message header to XML
5387            
5388             =head1 LICENSE AND COPYRIGHT
5389            
5390             Copyright (c) 2007 Martin Kutter. All rights reserved.
5391            
5392             This file is part of SOAP-WSDL. You may distribute/modify it under
5393             the same terms as perl itself
5394            
5395             =head1 AUTHOR
5396            
5397             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
5398            
5399             =head1 REPOSITORY INFORMATION
5400            
5401             $Rev: 861 $
5402             $LastChangedBy: kutterma $
5403             $Id: XSD.pm 861 2010-03-28 10:41:26Z kutterma $
5404             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Serializer/XSD.pm $
5405            
5406             =cut
5407            
5408             SOAP_WSDL_SERIALIZER_XSD
5409              
5410 6         15 $fatpacked{"SOAP/WSDL/Server.pm"} = <<'SOAP_WSDL_SERVER';
5411             package
5412             SOAP::WSDL::Server;
5413             use strict;
5414             use warnings;
5415             use Class::Std::Fast::Storable;
5416             use Scalar::Util qw(blessed);
5417             use SOAP::WSDL::Factory::Deserializer;
5418             use SOAP::WSDL::Factory::Serializer;
5419            
5420             use version; our $VERSION = qv('2.00.99_3');
5421            
5422             my %dispatch_to_of :ATTR(:name<dispatch_to> :default<()>);
5423             my %action_map_ref_of :ATTR(:name<action_map_ref> :default<{}>);
5424             my %method_map_ref_of :ATTR(:name<method_map_ref> :default<{}>);
5425             my %class_resolver_of :ATTR(:name<class_resolver> :default<()>);
5426             my %deserializer_of :ATTR(:name<deserializer> :default<()>);
5427             my %serializer_of :ATTR(:name<serializer> :default<()>);
5428             my %soap_version_of :ATTR(:name<soap_veraion> :default<1.1>);
5429            
5430             sub handle {
5431             my $self = shift;
5432             my $request = shift; # this involves copying the request... once
5433             my $ident = ident $self;
5434            
5435            
5436             # we only support 1.1 now...
5437             $deserializer_of{ $ident } ||= SOAP::WSDL::Factory::Deserializer->get_deserializer({
5438             soap_version => $soap_version_of{ $ident },
5439             });
5440             $serializer_of{ $ident } ||= SOAP::WSDL::Factory::Serializer->get_serializer({
5441             soap_version => $soap_version_of{ $ident },
5442             });
5443            
5444             # lookup method name by SOAPAction
5445             # TODO: factor out dispatcher logic into dispatcher factory + dispatcher
5446             # classes
5447             # $dispatcher_of{ $ident } ||= SOAP::WSDL::Factory::Dispatcher->get_dispatcher({});
5448            
5449             my $soap_action = $request->header('SOAPAction');
5450             $soap_action = '' if ! defined $soap_action;
5451             $soap_action =~s{ \A(?:"|')(.+)(?:"|') \z }{$1}xms;
5452             my $method_name = $action_map_ref_of{ $ident }->{ $soap_action };
5453            
5454             if ( ! $dispatch_to_of{ $ident } ) {
5455             die $deserializer_of{ $ident }->generate_fault({
5456             code => 'SOAP-ENV:Server',
5457             role => 'urn:localhost',
5458             message => "No handler registered",
5459             });
5460             };
5461            
5462             if ( ! defined $request->header('SOAPAction') ) {
5463             die $deserializer_of{ $ident }->generate_fault({
5464             code => 'SOAP-ENV:Server',
5465             role => 'urn:localhost',
5466             message => "Not found: No SOAPAction given",
5467             });
5468             };
5469            
5470             if ( ! defined $method_name) {
5471             die $deserializer_of{ $ident }->generate_fault({
5472             code => 'SOAP-ENV:Server',
5473             role => 'urn:localhost',
5474             message => "Not found: No method found for the SOAPAction '$soap_action'",
5475             });
5476             };
5477            
5478             # initialize deserializer from caller
5479             if ( $method_map_ref_of{$ident} && $deserializer_of{ $ident }->can('init_from_caller') ) {
5480             $deserializer_of{ $ident }->init_from_caller(
5481             $self, $method_map_ref_of{ $ident }->{ $method_name }
5482             );
5483             }
5484             else {
5485             # for compatibility only
5486             $deserializer_of{ $ident }->set_class_resolver( $class_resolver_of{ $ident } )
5487             if ( $deserializer_of{ $ident }->can('set_class_resolver') );
5488            
5489             $deserializer_of{ $ident }->set_body_parts(
5490             $method_map_ref_of{ $ident }->{ $method_name }->{ body }->{ parts }
5491             ) if ( $deserializer_of{ $ident }->can('set_body_parts') );
5492            
5493             $deserializer_of{ $ident }->set_header_parts(
5494             $method_map_ref_of{ $ident }->{ $method_name }->{ header }->{ parts }
5495             ) if ( $deserializer_of{ $ident }->can('set_header_parts') );
5496             }
5497            
5498             # Try deserializing response
5499             my ($body, $header) = eval {
5500             $deserializer_of{ $ident }->deserialize( $request->content() );
5501             };
5502             if ($@) {
5503             die $deserializer_of{ $ident }->generate_fault({
5504             code => 'soap:Server',
5505             role => 'urn:localhost',
5506             message => "Error deserializing message: $@. \n"
5507             });
5508             };
5509             if ( blessed($body) && $body->isa('SOAP::WSDL::SOAP::Typelib::Fault11') ) {
5510             die $body;
5511             }
5512            
5513             # $dispatcher_of{ $ident }->dispatch({
5514             # soap_action => $soap_action,
5515             # request_body => $body,
5516             # request_header => $header,
5517             # });
5518            
5519             # find method in handling class/object
5520             my $method_ref = $dispatch_to_of{ $ident }->can($method_name);
5521            
5522             if ( ! $method_ref) {
5523             die $deserializer_of{ $ident }->generate_fault({
5524             code => 'SOAP-ENV:Server',
5525             role => 'urn:localhost',
5526             message => "Not implemented: The handler does not implement the method $method_name",
5527             });
5528             };
5529            
5530             my ($response_body, $response_header) = $method_ref->($dispatch_to_of{ $ident }, $body, $header );
5531            
5532             return $serializer_of{ $ident }->serialize({
5533             body => $response_body,
5534             header => $response_header,
5535             });
5536             }
5537            
5538             1;
5539            
5540             =pod
5541            
5542             =head1 NAME
5543            
5544             SOAP::WSDL::Server - WSDL based SOAP server base class
5545            
5546             =head1 SYNOPSIS
5547            
5548             Don't use directly, use the SOAP::WSDL::Server::* subclasses
5549             instead.
5550            
5551             =head1 DESCRIPTION
5552            
5553             SOAP::WSDL::Server basically follows the architecture sketched below
5554             (though dispatcher classes are not implemented yet)
5555            
5556             SOAP Request SOAP Response
5557             | ^
5558             V |
5559             ------------------------------------------
5560             | SOAP::WSDL::Server |
5561             | -------------------------------------- |
5562             | | Transport Class | |
5563             | |--------------------------------------| |
5564             | | Deserializer | Serializer | |
5565             | |--------------------------------------| |
5566             | | Dispatcher | |
5567             | -------------------------------------- |
5568             ------------------------------------------
5569             | calls ^
5570             v | returns
5571             -------------------------------------
5572             | Handler |
5573             -------------------------------------
5574            
5575             All of the components (Transport class, deserializer, dispatcher and
5576             serializer) are implemented as plugins.
5577            
5578             The architecture is not implemented as planned yet, but the dispatcher is
5579             currently part of SOAP::WSDL::Server, which aggregates serializer and
5580             deserializer, and is subclassed by transport classes (of which
5581             SOAP::WSDL::Server::CGI is the only implemented one yet).
5582            
5583             The dispatcher is currently based on the SOAPAction header. This does not
5584             comply to the WS-I basic profile, which declares the SOAPAction as optional.
5585            
5586             The final dispatcher will be based on wire signatures (i.e. the classes
5587             of the deserialized messages).
5588            
5589             A hash-based dispatcher could be implemented by examining the top level
5590             hash keys.
5591            
5592             =head1 EXCEPTION HANDLING
5593            
5594             =head2 Builtin exceptions
5595            
5596             SOAP::WSDL::Server handles the following errors itself:
5597            
5598             In case of errors, a SOAP Fault containing an appropriate error message
5599             is returned.
5600            
5601             =over
5602            
5603             =item * XML parsing errors
5604            
5605             =item * Configuration errors
5606            
5607             =back
5608            
5609             =head2 Throwing exceptions
5610            
5611             The proper way to throw a exception is just to die -
5612             SOAP::WSDL::Server::CGI catches the exception and sends a SOAP Fault
5613             back to the client.
5614            
5615             If you want more control over the SOAP Fault sent to the client, you can
5616             die with a SOAP::WSDL::SOAP::Fault11 object - or just let the
5617             SOAP::Server's deserializer create one for you:
5618            
5619             my $soap = MyServer::SomeService->new();
5620            
5621             die $soap->get_deserializer()->generate_fault({
5622             code => 'SOAP-ENV:Server',
5623             role => 'urn:localhost',
5624             message => "The error message to pas back",
5625             detail => "Some details on the error",
5626             });
5627            
5628             You may use any other object as exception, provided it has a
5629             serialize() method which returns the object's XML representation.
5630            
5631             =head2 Subclassing
5632            
5633             To write a transport-specific SOAP Server, you should subclass
5634             SOAP::WSDL::Server.
5635            
5636             See the C<SOAP::WSDL::Server::*> modules for examples.
5637            
5638             A SOAP Server must call the following method to actually handle the request:
5639            
5640             =head3 handle
5641            
5642             Handles the SOAP request.
5643            
5644             Returns the response message as XML.
5645            
5646             Expects a C<HTTP::Request> object as only parameter.
5647            
5648             You may use any other object as parameter, as long as it implements the
5649             following methods:
5650            
5651             =over
5652            
5653             =item * header
5654            
5655             Called as header('SOAPAction'). Must return the corresponding HTTP header.
5656            
5657             =item * content
5658            
5659             Returns the request message
5660            
5661             =back
5662            
5663             =head1 LICENSE AND COPYRIGHT
5664            
5665             Copyright 2004-2008 Martin Kutter.
5666            
5667             This file is part of SOAP-WSDL. You may distribute/modify it under the same
5668             terms as perl itself
5669            
5670             =head1 AUTHOR
5671            
5672             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
5673            
5674             =head1 REPOSITORY INFORMATION
5675            
5676             $Rev: 391 $
5677             $LastChangedBy: kutterma $
5678             $Id: Client.pm 391 2007-11-17 21:56:13Z kutterma $
5679             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Client.pm $
5680            
5681             =cut
5682             SOAP_WSDL_SERVER
5683              
5684 6         14 $fatpacked{"SOAP/WSDL/Server/CGI.pm"} = <<'SOAP_WSDL_SERVER_CGI';
5685             package
5686             SOAP::WSDL::Server::CGI;
5687             use strict;
5688             use warnings;
5689             use Encode;
5690             use Encode;
5691            
5692             use HTTP::Request;
5693             use HTTP::Response;
5694             use HTTP::Status;
5695             use HTTP::Headers;
5696             use Scalar::Util qw(blessed);
5697            
5698             use Class::Std::Fast::Storable;
5699            
5700             use base qw(SOAP::WSDL::Server);
5701            
5702             use version; our $VERSION = qv('2.00.99_3');
5703            
5704             # mostly copied from SOAP::Lite. Unfortunately we can't use SOAP::Lite's CGI
5705             # server directly - we would have to swap out it's base class...
5706             #
5707             # This should be a warning for us: We should not handle methods via inheritance,
5708             # but via some plugin mechanism, to allow alternative handlers to be plugged
5709             # in.
5710            
5711             sub handle {
5712             my $self = shift;
5713             my $response;
5714             my $length = $ENV{'CONTENT_LENGTH'} || 0;
5715            
5716             if (!$length) {
5717             $response = HTTP::Response->new(411); # LENGTH REQUIRED
5718             $self->_output($response);
5719             return;
5720             }
5721            
5722             if (exists $ENV{EXPECT} && $ENV{EXPECT} =~ /\b100-Continue\b/i) {
5723             print "HTTP/1.1 100 Continue\r\n\r\n";
5724             }
5725            
5726             my $content = q{};
5727             my $buffer;
5728            
5729             # do we need to use bytes; here ?
5730             binmode(STDIN);
5731             while (read(STDIN,$buffer,$length - length($content))) {
5732             $content .= $buffer;
5733             }
5734            
5735             my $request = HTTP::Request->new(
5736             $ENV{'REQUEST_METHOD'} || '' => $ENV{'SCRIPT_NAME'},
5737             HTTP::Headers->new(
5738             map {
5739             (/^HTTP_(.+)/i
5740             ? ($1=~m/SOAPACTION/)
5741             ?('SOAPAction')
5742             :($1)
5743             : $_
5744             ) => $ENV{$_}
5745             } keys %ENV),
5746             $content,
5747             );
5748            
5749             # we copy the response message around here.
5750             # Passing by reference would be much better...
5751             my $response_message = eval { $self->SUPER::handle($request) };
5752             # caveat: SOAP::WSDL::SOAP::Typelib::Fault11 is false in bool context...
5753             if ($@ || blessed $@) {
5754             my $exception = $@;
5755             $response = HTTP::Response->new(500);
5756             $response->header('Content-type' => 'text/xml; charset="utf-8"');
5757             if (blessed($exception)) {
5758             $response->content( $self->get_serializer->serialize({
5759             body => $exception
5760             })
5761             );
5762             }
5763             else {
5764             $response->content($exception);
5765             }
5766             }
5767             else {
5768             $response = HTTP::Response->new(200);
5769             $response->header('Content-type' => 'text/xml; charset="utf-8"');
5770             $response->content( encode('utf8', $response_message ) );
5771             {
5772             use bytes;
5773             $response->header('Content-length', length $response_message);
5774             }
5775             }
5776            
5777             $self->_output($response);
5778             return;
5779             }
5780            
5781             sub _output :PRIVATE {
5782             my ($self, $response) = @_;
5783             # imitate nph- cgi for IIS (pointed by Murray Nesbitt)
5784             my $status = defined($ENV{'SERVER_SOFTWARE'}) && $ENV{'SERVER_SOFTWARE'}=~/IIS/
5785             ? $ENV{SERVER_PROTOCOL} || 'HTTP/1.0'
5786             : 'Status:';
5787            
5788             my $code = $response->code;
5789             binmode(STDOUT);
5790             print STDOUT "$status $code ", HTTP::Status::status_message($code)
5791             , "\015\012", $response->headers_as_string("\015\012")
5792             , "\015\012", $response->content;
5793             }
5794            
5795             1;
5796            
5797             =pod
5798            
5799             =head1 NAME
5800            
5801             SOAP::WSDL::Server::CGI - CGI based SOAP server
5802            
5803             =head1 SYNOPSIS
5804            
5805             use MyServer::TestService::TestPort;
5806             my $server = MyServer::TestService::TestPort->new({
5807             dispatch_to => 'main',
5808             transport_class => 'SOAP::WSDL::Server::CGI', # optional, default
5809             });
5810             $server->handle();
5811            
5812             =head1 USAGE
5813            
5814             To use SOAP::WSDL::Server::CGI efficiently, you should first create a server
5815             interface using L<wsdl2perl.pl|wsdl2perl.pl>.
5816            
5817             SOAP::WSDL::Server dispatches all calls to appropriately named methods in the
5818             class or object set via C<dispatch_to>.
5819            
5820             See the generated server class on details.
5821            
5822             =head1 DESCRIPTION
5823            
5824             Lightweight CGI based SOAP server. SOAP::WSDL::Server::CGI does not provide
5825             the fancier things of CGI handling, like URL parsing, parameter extraction
5826             or the like, but provides a basic SOAP server using SOAP::WSDL::Server.
5827            
5828             =head1 METHODS
5829            
5830             =head2 handle
5831            
5832             See synopsis above.
5833            
5834             =head1 LICENSE AND COPYRIGHT
5835            
5836             Copyright 2004-2008 Martin Kutter.
5837            
5838             This file is part of SOAP-WSDL. You may distribute/modify it under the same
5839             terms as perl itself
5840            
5841             =head1 AUTHOR
5842            
5843             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
5844            
5845             =head1 REPOSITORY INFORMATION
5846            
5847             $Rev: 391 $
5848             $LastChangedBy: kutterma $
5849             $Id: Client.pm 391 2007-11-17 21:56:13Z kutterma $
5850             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Client.pm $
5851            
5852             =cut
5853             SOAP_WSDL_SERVER_CGI
5854              
5855 6         14 $fatpacked{"SOAP/WSDL/Server/Mod_Perl2.pm"} =
5856             <<'SOAP_WSDL_SERVER_MOD_PERL2';
5857             package
5858             SOAP::WSDL::Server::Mod_Perl2;
5859             use strict;
5860             use warnings;
5861             use base qw(SOAP::WSDL::Server);
5862             use Scalar::Util qw(blessed);
5863            
5864             use HTTP::Request ();
5865             use Apache2::RequestIO (); # $r->read()
5866             use Apache2::RequestRec (); # $r->headers_in
5867             use Apache2::RequestUtil(); # $r->dir_config()
5868             use APR::Table (); # $r->headers_in->get()
5869             use Apache2::Log (); # $r->log
5870             use Apache2::Const -compile => qw(
5871             OK
5872             SERVER_ERROR
5873             HTTP_LENGTH_REQUIRED
5874             );
5875            
5876             use version; our $VERSION = qv('2.00.99_3');
5877            
5878             my %LOADED_OF = ();
5879            
5880             sub handler {
5881             my $r = shift;
5882             my $rlog = $r->log();
5883            
5884             #
5885             # Set up section; import requested modules, throwing errors if we're
5886             # unable to do so. For maximum performance, this should be re-worked
5887             # to use perl-based Apache directives rather than dir_config(), since
5888             # the former happens at startup time and the latter at request time.
5889            
5890             #
5891             # dispatch_to
5892             my $dispatch_to = $r->dir_config('dispatch_to');
5893             if (! $dispatch_to) {
5894             $rlog->error("No 'dispatch_to' variable set in httpd.conf");
5895             return Apache2::Const::SERVER_ERROR;
5896             }
5897            
5898             if (! exists $LOADED_OF{$dispatch_to}) {
5899             eval "require $dispatch_to";
5900             if ($@) {
5901             $rlog->error("Failed to require [$dispatch_to]: $@");
5902             return Apache2::Const::SERVER_ERROR;
5903             }
5904             $LOADED_OF{$dispatch_to} = undef;
5905             }
5906            
5907             #
5908             # SOAP service
5909             my $soap_service_package = $r->dir_config('soap_service');
5910             if (! $soap_service_package) {
5911             $rlog->error("No 'soap_service' variable set in httpd.conf");
5912             return Apache2::Const::SERVER_ERROR;
5913             }
5914            
5915             if (! exists $LOADED_OF{$soap_service_package}) {
5916             eval "require $soap_service_package";
5917             if ($@) {
5918             $rlog->error("Failed to require [$soap_service_package]: $@");
5919             return Apache2::Const::SERVER_ERROR;
5920             }
5921             $LOADED_OF{$soap_service_package} = undef;
5922             }
5923            
5924             #
5925             # transport_class (optional)
5926             my $transport_class = $r->dir_config('transport_class');
5927             if ($transport_class) {
5928             eval "require $transport_class";
5929             if ($@) {
5930             $rlog->error("Failed to require [$transport_class]: $@");
5931             return Apache2::Const::SERVER_ERROR;
5932             }
5933             }
5934             else {
5935             #
5936             # if no transport class was specified, use this package's handle()
5937             # method
5938             $transport_class = __PACKAGE__;
5939             }
5940            
5941             #
5942             # instantiate SOAP server object
5943             my $server = $soap_service_package->new({
5944             dispatch_to => $dispatch_to, # methods
5945             transport_class => $transport_class, # handle() call
5946             });
5947            
5948             my $response_msg = $server->handle($r);
5949             if ($response_msg =~ /^\d{3}$/) {
5950             #
5951             # a 3-digit number is presumed to be an HTTP return status; since
5952             # we got this and not a SOAP response, it's presumed to be an
5953             # error; pass it back to the client as-is
5954             $rlog->error("Dispatcher returned HTTP $response_msg");
5955             return $response_msg;
5956             }
5957            
5958             if ($response_msg) {
5959             $r->content_type('text/xml; charset="utf-8"');
5960             $r->print($response_msg);
5961             return Apache2::Const::OK;
5962             }
5963             else {
5964             $rlog->error("No response returned from dispatcher");
5965             return Apache2::Const::SERVER_ERROR;
5966             }
5967             }
5968            
5969             sub handle {
5970             my ($self, $r) = @_;
5971             my $rlog = $r->log();
5972            
5973             my $length = $r->headers_in->get('content-length');
5974             if (! $length) {
5975             $rlog->error("No content-length provided");
5976             # TODO maybe throw instead of returning a HTTP code?
5977             # ... it's an exception, anyway...
5978             return Apache2::Const::HTTP_LENGTH_REQUIRED;
5979             }
5980            
5981             # read may return less than requested - read until there's no more...
5982             # TODO: We should note that LimitRequestBody is a must in apache config
5983             my ($buffer, $read_length);
5984             my $content = q{};
5985             while ($read_length = $r->read($buffer, $length)) {
5986             $content .= $buffer;
5987             }
5988            
5989             if ($length != length $content) {
5990             $rlog->error("Read length mismatch; read [" . length($content) . "] bytes but received [$length] bytes");
5991             return Apache2::Const::SERVER_ERROR;
5992             }
5993            
5994             # Shamelessly copied (with mild tweaks) from SOAP::WSDL::Server::CGI
5995             # ... which was as shamelessly copied from SOAP::Transport::HTTP...
5996             my $request = HTTP::Request->new(
5997             $r->method => $r->uri,
5998             HTTP::Headers->new(
5999             SOAPAction => $r->headers_in()->get('SOAPAction'),
6000             ),
6001             $content,
6002             );
6003            
6004             my $response_message = eval { $self->SUPER::handle($request) };
6005            
6006             # TODO return response if @$ is a SOAP::WSDL::XSD::Typelib::Builtin::anyType object
6007             if ($@ || blessed($@)) {
6008             $rlog->error("Failed to handle request: $@");
6009             return Apache2::Const::SERVER_ERROR;
6010             }
6011             else {
6012             return $response_message;
6013             }
6014             }
6015            
6016             1;
6017            
6018             __END__
6019            
6020             =pod
6021            
6022             =head1 NAME
6023            
6024             SOAP::WSDL::Server::Mod_Perl2 - mod_perl based SOAP server using SOAP::WSDL
6025            
6026             =head1 DESCRIPTION
6027            
6028             Perl module providing a mod_perl2-based SOAP server using SOAP::WSDL
6029            
6030             =head1 CONFIGURATION
6031            
6032             Configuration is managed through the use of PerlSetVar directives.
6033             The following variables are available:
6034            
6035             =head2 dispatch_to
6036            
6037             Takes as a single argument the package name of the module which contains
6038             the methods which handle SOAP requests.
6039            
6040             PerlSetVar dispatch_to "WebPackage::SOAPMethods"
6041            
6042             =head2 soap_service
6043            
6044             Takes as a single argument the package name of the Server module
6045             generated by SOAP::WSDL using
6046            
6047             wsdl2perl.pl --server file:///path/to/your/wsdl
6048            
6049             By default, the name of the package is MyServer::$SERVICENAME::$PORTTYPE.
6050            
6051             EXAMPLE: Given this sample WSDL which wsdl2perl.pl was run against to generate
6052             perl packages:
6053            
6054             <wsdl:portType name="WebServiceSoap">
6055             [...]
6056             </wsdl:portType>
6057            
6058             [...]
6059            
6060             <wsdl:service name="WebService">
6061             <wsdl:port name="WebServiceSoap" binding="tns:WebServiceSoap">
6062             <soap:address location="http://www.example.com/WebService"/>
6063             </wsdl:port>
6064             </wsdl:service>
6065            
6066             The following directive would be correct:
6067            
6068             PerlSetVar soap_service "MyServer::WebService::WebServiceSoap"
6069            
6070             =head2 transport_class [OPTIONAL]
6071            
6072             Takes as a single argument the package name of the perl module containing a
6073             handle() method used to assemble the HTTP request which will be passed to the
6074             methods in your L<dispatch_to> module (see above). A default handle() method
6075             is supplied in this module which should handle most common cases.
6076            
6077             handle() is called with the following parameters:
6078            
6079             $r - Apache::RequestRec object
6080            
6081             =head1 EXAMPLES
6082            
6083             The following snippet added to httpd.conf will enable a SOAP server at
6084             /WebService on your webserver:
6085            
6086             <Location /WebService>
6087             SetHandler perl-script
6088             PerlResponseHandler SOAP::WSDL::Server::Mod_Perl2
6089             PerlSetVar dispatch_to "WebPackage::SOAPMethods"
6090             PerlSetVar soap_service "MyServer::WebService::WebServiceSoap"
6091             </Location>
6092            
6093             =head1 PERFORMANCE
6094            
6095             On my machine, a simple SOAP server (the HelloWorld service from the examples)
6096             needs around 20s to process 300 requests to a CGI script implemented with
6097             SOAP::WSDL::Server::CGI, around 4.5s to the same CGI with mod_perl enabled,
6098             and around 3.2s with SOAP::WSDL::Server::Mod_Perl2. All these figures
6099             include the time for creating the request and parsing the response.
6100            
6101             As general advice, using mod_perl is highly recommended in high-performance
6102             environments. Using SOAP::WSDL::Server::Mod_Perl2 yields an extra 20% speedup
6103             compared with mod_perl enabled CGI scripts - and it allows one to configure
6104             SOAP servers in the Apache config.
6105            
6106             =head1 THREAD SAFETY
6107            
6108             SOAP::WSDL uses Class::Std::Fast, which is not guaranteed to be threadsafe
6109             yet. Thread safety in Class::Std::Fast is dependent on whether
6110            
6111             my $foo = $bar++;
6112            
6113             is an atomic operation. I haven't found out yet.
6114            
6115             A load test on a single CPU machine with 4 clients using the worker mpm
6116             did not reveal any threading issues - but that does not mean there are none.
6117            
6118             =head1 CREDITS
6119            
6120             Contributed (along with lots of other little improvements) by Noah Robin.
6121            
6122             Thanks!
6123            
6124             =head1 LICENSE AND COPYRIGHT
6125            
6126             This file is part of SOAP-WSDL. You may distribute/modify it under
6127             the same terms as perl itself
6128            
6129             =head1 AUTHOR
6130            
6131             Noah Robin E<lt>noah.robin gmail.comE<gt>
6132            
6133             Based on SOAP::WSDL::Server::CGI, by Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
6134            
6135             =head1 REPOSITORY INFORMATION
6136            
6137             $Rev: 583 $
6138             $LastChangedBy: kutterma $
6139             $Id: $
6140             $HeadURL: $
6141            
6142             =cut
6143             SOAP_WSDL_SERVER_MOD_PERL2
6144              
6145 6         15 $fatpacked{"SOAP/WSDL/Server/Simple.pm"} = <<'SOAP_WSDL_SERVER_SIMPLE';
6146             package
6147             SOAP::WSDL::Server::Simple;
6148             use strict;
6149             use warnings;
6150            
6151             use Encode;
6152            
6153             use HTTP::Request;
6154             use HTTP::Response;
6155             use HTTP::Status;
6156             use HTTP::Headers;
6157             use Scalar::Util qw(blessed);
6158            
6159             use Class::Std::Fast::Storable;
6160            
6161             use base qw(SOAP::WSDL::Server);
6162            
6163             use version; our $VERSION = qv('2.00.99_3');
6164            
6165             # mostly copied from SOAP::Lite. Unfortunately we can't use SOAP::Lite's CGI
6166             # server directly - we would have to swap out it's base class...
6167             #
6168             # This should be a warning for us: We should not handle methods via inheritance,
6169             # but via some plugin mechanism, to allow alternative handlers to be plugged
6170             # in.
6171            
6172             sub handle {
6173             my ($self, $cgi) = @_;
6174            
6175             my $response;
6176            
6177             my $content = $cgi->param('POSTDATA');
6178            
6179             my $request = HTTP::Request->new(
6180             $ENV{'REQUEST_METHOD'} || '' => $ENV{'SCRIPT_NAME'},
6181             HTTP::Headers->new(
6182             map {
6183             (/^HTTP_(.+)/i
6184             ? ($1=~m/SOAPACTION/)
6185             ?('SOAPAction')
6186             :($1)
6187             : $_
6188             ) => $ENV{$_}
6189             } keys %ENV),
6190             $content,
6191             );
6192            
6193             # we copy the response message around here.
6194             # Passing by reference would be much better...
6195             my $response_message = eval { $self->SUPER::handle($request) };
6196            
6197             # caveat: SOAP::WSDL::SOAP::Typelib::Fault11 is false in bool context...
6198             if ($@ || blessed $@) {
6199             my $exception = $@;
6200             $response = HTTP::Response->new(500);
6201             $response->header('Content-type' => 'text/xml; charset="utf-8"');
6202             if (blessed($exception)) {
6203             $response->content( $self->get_serializer->serialize({
6204             body => $exception
6205             })
6206             );
6207             }
6208             else {
6209             $response->content($exception);
6210             }
6211             }
6212             else {
6213             $response = HTTP::Response->new(200);
6214             $response->header('Content-type' => 'text/xml; charset="utf-8"');
6215             $response->content( encode('utf8', $response_message ) );
6216             {
6217             use bytes;
6218             $response->header('Content-length', length $response_message);
6219             }
6220             }
6221            
6222             $self->_output($response);
6223             return;
6224             }
6225            
6226             sub _output :PRIVATE {
6227             my ($self, $response) = @_;
6228             my $code = $response->code;
6229             binmode(STDOUT);
6230             print STDOUT "HTTP/1.0 $code ", HTTP::Status::status_message($code)
6231             , "\015\012", $response->headers_as_string("\015\012")
6232             , "\015\012", $response->content;
6233            
6234             warn "HTTP/1.0 $code ", HTTP::Status::status_message($code)
6235             , "\015\012", $response->headers_as_string("\015\012")
6236             , $response->content, "\n\n";
6237             }
6238            
6239             1;
6240            
6241             SOAP_WSDL_SERVER_SIMPLE
6242              
6243 6         13 $fatpacked{"SOAP/WSDL/Service.pm"} = <<'SOAP_WSDL_SERVICE';
6244             package
6245             SOAP::WSDL::Service;
6246             use strict;
6247             use warnings;
6248             use Class::Std::Fast::Storable;
6249             use base qw(SOAP::WSDL::Base);
6250            
6251             use version; our $VERSION = qv('2.00.99_3');
6252            
6253             my %port_of :ATTR(:name<port> :default<[]>);
6254            
6255             1;
6256             SOAP_WSDL_SERVICE
6257              
6258 6         12 $fatpacked{"SOAP/WSDL/Starter.pm"} = <<'SOAP_WSDL_STARTER';
6259             package
6260             SOAP::WSDL::Starter;
6261             {
6262             use strict;
6263             use warnings;
6264             use parent qw(Module::Starter::Simple);
6265             our $VERSION = 2.01;
6266            
6267             sub create_build {
6268             my $self = shift;
6269             my $builder = q{Module::Build};
6270             my $builder_set = Module::Starter::BuilderSet->new();
6271            
6272             # compile some build instructions, create a list of files generated
6273             # by the builders' create_* methods, and call said methods
6274            
6275             my @build_instructions;
6276             my @files;
6277            
6278             push @build_instructions,
6279             'To install this module, run the following commands:',
6280             join( "\n",
6281             map { "\t$_" } $builder_set->instructions_for_builder($builder) )
6282             ;
6283            
6284             push( @files, $builder_set->file_for_builder($builder) );
6285            
6286             my $build_method = $builder_set->method_for_builder($builder);
6287             $self->$build_method( $self->{main_module} );
6288            
6289             mkdir "$self->{basedir}/wsdl" or warn $!;
6290            
6291             return (
6292             files => [@files],
6293             instructions => join( "\n\n", @build_instructions ),
6294             );
6295             }
6296            
6297             sub Build_PL_guts {
6298             my $self = shift;
6299             my $main_module = shift;
6300             my $main_pm_file = shift;
6301            
6302             (my $author = "$self->{author} <$self->{email}>") =~ s/'/\'/g;
6303            
6304             return <<"HERE";
6305             use strict;
6306             use warnings;
6307             use SOAP::WSDL::Build;
6308            
6309             my \$builder = SOAP::WSDL::Build->new(
6310             module_name => '$main_module',
6311             license => '$self->{license}',
6312             dist_author => '$author',
6313             dist_version_from => '$main_pm_file',
6314             build_requires => {
6315             'Test::More' => 0,
6316             'SOAP::WSDL::Build' => 2.01,
6317             },
6318             requires => {
6319             'SOAP::WSDL' => 2.01
6320             },
6321             wsdl2perl => [
6322             {
6323             location => 'wsdl/Add_WSDL_here',
6324             prefix => '$main_module\::SOAP',
6325             }
6326             ],
6327             add_to_cleanup => [ '$self->{distro}-*' ],
6328             create_makefile_pl => 'small',
6329             );
6330            
6331             \$builder->create_build_script();
6332             HERE
6333             }
6334             }
6335            
6336             1;
6337             SOAP_WSDL_STARTER
6338              
6339 6         14 $fatpacked{"SOAP/WSDL/Transport/HTTP.pm"} = <<'SOAP_WSDL_TRANSPORT_HTTP';
6340             package
6341             SOAP::WSDL::Transport::HTTP;
6342             use strict; use warnings;
6343             use base qw(LWP::UserAgent);
6344            
6345             use version; our $VERSION = qv('2.00.99_3');
6346            
6347             # create methods normally inherited from SOAP::Client
6348             SUBFACTORY: {
6349             no strict qw(refs);
6350             foreach my $method ( qw(code message status is_success) ) {
6351             *{ $method } = sub {
6352             my $self = shift;
6353             return $self->{ $method } if not @_;
6354             return $self->{ $method } = shift;
6355             };
6356             }
6357             }
6358            
6359             sub _agent {
6360             return qq[SOAP::WSDL $VERSION];
6361             }
6362            
6363             sub send_receive {
6364             my ($self, %parameters) = @_;
6365             my ($envelope, $soap_action, $endpoint, $encoding, $content_type) =
6366             @parameters{qw(envelope action endpoint encoding content_type)};
6367            
6368             $encoding = defined($encoding)
6369             ? lc($encoding)
6370             : 'utf-8';
6371            
6372             $content_type = "text/xml; charset=$encoding"
6373             if not defined($content_type);
6374             # what's this all about?
6375             # unfortunately combination of LWP and Perl 5.6.1 and later has bug
6376             # in sending multibyte characters. LWP uses length() to calculate
6377             # content-length header and starting 5.6.1 length() calculates chars
6378             # instead of bytes. 'use bytes' in THIS file doesn't work, because
6379             # it's lexically scoped. Unfortunately, content-length we calculate
6380             # here doesn't work either, because LWP overwrites it with
6381             # content-length it calculates (which is wrong) AND uses length()
6382             # during syswrite/sysread, so we are in a bad shape anyway.
6383             #
6384             # what to do? we calculate proper content-length (using
6385             # bytelength() function from SOAP::Utils) and then drop utf8 mark
6386             # from string (doing pack with 'C0A*' modifier) if length and
6387             # bytelength are not the same
6388            
6389             # use bytes is lexically scoped
6390             my $bytelength = do { use bytes; length $envelope };
6391             $envelope = pack('C0A*', $envelope)
6392             if length($envelope) != $bytelength;
6393            
6394             my $request = HTTP::Request->new( 'POST',
6395             $endpoint,
6396             [ 'Content-Type', "$content_type",
6397             'Content-Length', $bytelength,
6398             'SOAPAction', $soap_action,
6399             ],
6400             $envelope );
6401            
6402             my $response = $self->request( $request );
6403            
6404             $self->code( $response->code);
6405             $self->message( $response->message);
6406             $self->is_success($response->is_success);
6407             $self->status($response->status_line);
6408            
6409             return $response->content();
6410             }
6411            
6412             1;
6413            
6414             =pod
6415            
6416             =head1 NAME
6417            
6418             SOAP::WSDL::Transport::HTTP - Fallback http(s) transport class
6419            
6420             =head1 DESCRIPTION
6421            
6422             Provides a thin transport class used by SOAP::WSDL::Transport when
6423             SOAP::Lite is not available.
6424            
6425             =head1 LICENSE AND COPYRIGHT
6426            
6427             Copyright (c) 2007 Martin Kutter. All rights reserved.
6428            
6429             This file is part of SOAP-WSDL. You may distribute/modify it under
6430             the same terms as perl itself
6431            
6432             =head1 AUTHOR
6433            
6434             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
6435            
6436             =head1 REPOSITORY INFORMATION
6437            
6438             $Rev: 861 $
6439             $LastChangedBy: kutterma $
6440             $Id: HTTP.pm 861 2010-03-28 10:41:26Z kutterma $
6441             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/Transport/HTTP.pm $
6442            
6443             =cut
6444            
6445             SOAP_WSDL_TRANSPORT_HTTP
6446              
6447 6         13 $fatpacked{"SOAP/WSDL/Transport/Loopback.pm"} =
6448             <<'SOAP_WSDL_TRANSPORT_LOOPBACK';
6449             package
6450             SOAP::WSDL::Transport::Loopback;
6451             use strict;
6452             use warnings;
6453             use Class::Std::Fast::Storable constructor => 'basic';
6454             use SOAP::WSDL::Factory::Transport;
6455            
6456             use version; our $VERSION = qv('2.00.99_3');
6457            
6458             # register on loading
6459             SOAP::WSDL::Factory::Transport->register( http => __PACKAGE__ );
6460             SOAP::WSDL::Factory::Transport->register( https => __PACKAGE__ );
6461            
6462             my %code_of :ATTR(:name<code> :default<()>);
6463             my %status_of :ATTR(:name<status> :default<()>);
6464             my %message_of :ATTR(:name<message> :default<()>);
6465             my %is_success_of :ATTR(:name<is_success> :default<()>);
6466            
6467             # create methods normally inherited from SOAP::Client
6468             SUBFACTORY: {
6469             no strict qw(refs);
6470             foreach my $method ( qw(code message status is_success) ) {
6471             *{ $method } = *{ "get_$method" };
6472             }
6473             }
6474            
6475             sub send_receive {
6476             my ($self, %parameters) = @_;
6477             return $parameters{envelope};
6478             }
6479            
6480             Class::Std::initialize();
6481            
6482            
6483             1;
6484            
6485             =head1 NAME
6486            
6487             SOAP::WSDL::Transport::Test - Loopback transport class for SOAP::WSDL
6488            
6489             =head1 SYNOPSIS
6490            
6491             use SOAP::WSDL::Client;
6492             use SOAP::WSDL::Transport::Loopback;
6493            
6494             my $soap = SOAP::WSDL::Client->new()
6495             $soap->get_transport->set_base_dir('.');
6496             $soap->call('method', \%body, \%header);
6497            
6498             =head1 DESCRIPTION
6499            
6500             SOAP::WSDL::Transport::Loopback is a loopback test transport backend for
6501             SOAP::WSDL.
6502            
6503             When SOAP::WSDL::Transport::Loopback is used as transport backend, the
6504             request is returned as response. No data ever goes over the wire.
6505             This is particularly useful for testing SOAP::WSDL plugins and applications.
6506            
6507             =head1 LICENSE AND COPYRIGHT
6508            
6509             Copyright (c) 2007 Martin Kutter. All rights reserved.
6510            
6511             This file is part of SOAP-WSDL. You may distribute/modify it under
6512             the same terms as perl itself
6513            
6514             =head1 AUTHOR
6515            
6516             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
6517            
6518             =head1 REPOSITORY INFORMATION
6519            
6520             $Rev: 218 $
6521             $LastChangedBy: kutterma $
6522             $Id: HTTP.pm 218 2007-09-10 16:19:23Z kutterma $
6523             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Transport/HTTP.pm $
6524            
6525             =cut
6526             SOAP_WSDL_TRANSPORT_LOOPBACK
6527              
6528 6         11 $fatpacked{"SOAP/WSDL/Transport/Test.pm"} = <<'SOAP_WSDL_TRANSPORT_TEST';
6529             package
6530             SOAP::WSDL::Transport::Test;
6531             use strict;
6532             use warnings;
6533             use Class::Std::Fast::Storable;
6534             use SOAP::WSDL::Factory::Transport;
6535            
6536             use version; our $VERSION = qv('2.00.99_3');
6537            
6538             SOAP::WSDL::Factory::Transport->register( http => __PACKAGE__ );
6539             SOAP::WSDL::Factory::Transport->register( https => __PACKAGE__ );
6540            
6541             my %code_of :ATTR(:name<code> :default<()>);
6542             my %status_of :ATTR(:name<status> :default<()>);
6543             my %message_of :ATTR(:name<message> :default<()>);
6544             my %is_success_of :ATTR(:name<is_success> :default<()>);
6545             my %base_dir_of :ATTR(:name<base_dir> :init_arg<base_dir> :default<.>);
6546            
6547             # create methods normally inherited from SOAP::Client
6548             SUBFACTORY: {
6549             no strict qw(refs);
6550             foreach my $method ( qw(code message status is_success) ) {
6551             *{ $method } = *{ "get_$method" };
6552             }
6553             }
6554            
6555             sub send_receive {
6556             my ($self, %parameters) = @_;
6557             my ($envelope, $soap_action, $endpoint, $encoding, $content_type) =
6558             @parameters{qw(envelope action endpoint encoding content_type)};
6559            
6560             my $filename = $soap_action;
6561             $filename =~s{ \A(:?'|") }{}xms;
6562             $filename =~s{ (:?'|")\z }{}xms;
6563             $filename =~s{ \A [^:]+ : (:? /{2})? }{}xms;
6564            
6565             $filename = join '/', $base_dir_of{ ${ $self } }, "$filename.xml";
6566            
6567             if (not -r $filename) {
6568             warn "cannot access $filename";
6569             $self->set_code( 500 );
6570             $self->set_message( "Failed" );
6571             $self->set_is_success(0);
6572             $self->set_status("500 Failed");
6573             return;
6574             }
6575            
6576             open my $fh, '<', $filename or die "cannot open $filename: $!";
6577             binmode $fh;
6578             my $response = <$fh>;
6579             close $fh or die "cannot close $filename: $!";
6580            
6581             $self->set_code( 200 );
6582             $self->set_message( "OK" );
6583             $self->set_is_success(1);
6584             $self->set_status("200 OK");
6585             return $response;
6586             }
6587            
6588             1;
6589            
6590             =head1 NAME
6591            
6592             SOAP::WSDL::Transport::Test - Test transport class for SOAP::WSDL
6593            
6594             =head1 SYNOPSIS
6595            
6596             use SOAP::WSDL::Client;
6597             use SOAP::WSDL::Transport::Test;
6598            
6599             my $soap = SOAP::WSDL::Client->new()
6600             $soap->get_transport->set_base_dir('.');
6601             $soap->call('method', \%body, \%header);
6602            
6603             =head1 DESCRIPTION
6604            
6605             SOAP::WSDL::Transport::Test is a file-based test transport backend for
6606             SOAP::WSDL.
6607            
6608             When SOAP::WSDL::Transport::Test is used as transport backend, the reponse is
6609             read from a XML file and the request message is discarded. This is
6610             particularly useful for testing SOAP::WSDL plugins.
6611            
6612             =head2 Filename resolution
6613            
6614             SOAP::WSDL::Transport makes up the response XML file name from the SOAPAction
6615             of the request. The following filename is used:
6616            
6617             base_dir / soap_action .xml
6618            
6619             The protocol scheme (e.g. http:) and two heading slashes (//) are stripped from
6620             the soap_action.
6621            
6622             base_dir defaults to '.'
6623            
6624             Examples:
6625            
6626             SOAPAction: http://somewhere.over.the.rainbow/webservice/webservice.asmx
6627             Filename: ./somewhere.over.the.rainbow/webservice/webservice.asmx.xml
6628            
6629             SOAPAction: uri:MyWickedService/test
6630             Filename: ./MyWickedService/test.xml
6631            
6632            
6633             =head1 METHODS
6634            
6635             =head2 set_base_dir
6636            
6637             Sets the base directory SOAP::WSDL::Transport::Test should look for response
6638             files.
6639            
6640             =head1 LICENSE AND COPYRIGHT
6641            
6642             Copyright (c) 2007 Martin Kutter. All rights reserved.
6643            
6644             This file is part of SOAP-WSDL. You may distribute/modify it under
6645             the same terms as perl itself
6646            
6647             =head1 AUTHOR
6648            
6649             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
6650            
6651             =head1 REPOSITORY INFORMATION
6652            
6653             $Rev: 218 $
6654             $LastChangedBy: kutterma $
6655             $Id: HTTP.pm 218 2007-09-10 16:19:23Z kutterma $
6656             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Transport/HTTP.pm $
6657            
6658             =cut
6659             SOAP_WSDL_TRANSPORT_TEST
6660              
6661 6         14 $fatpacked{"SOAP/WSDL/TypeLookup.pm"} = <<'SOAP_WSDL_TYPELOOKUP';
6662             package
6663             SOAP::WSDL::TypeLookup;
6664             use strict;
6665             use warnings;
6666            
6667             use version; our $VERSION = qv('2.00.99_3');
6668            
6669             my %TYPE_FROM = (
6670             # wsdl:
6671             'http://schemas.xmlsoap.org/wsdl/' => {
6672             'import' => {
6673             type => 'HANDLER',
6674             method => 'wsdl_import',
6675             },
6676             binding => {
6677             type => 'CLASS',
6678             class => 'SOAP::WSDL::Binding',
6679             },
6680             definitions => {
6681             type => 'CLASS',
6682             class => 'SOAP::WSDL::Definitions',
6683             },
6684             portType => {
6685             type => 'CLASS',
6686             class => 'SOAP::WSDL::PortType',
6687             },
6688             message => {
6689             type => 'CLASS',
6690             class => 'SOAP::WSDL::Message',
6691             },
6692             part => {
6693             type => 'CLASS',
6694             class => 'SOAP::WSDL::Part',
6695             },
6696             service => {
6697             type => 'CLASS',
6698             class => 'SOAP::WSDL::Service',
6699             },
6700             port => {
6701             type => 'CLASS',
6702             class => 'SOAP::WSDL::Port',
6703             },
6704             operation => {
6705             type => 'CLASS',
6706             class => 'SOAP::WSDL::Operation',
6707             },
6708             input => {
6709             type => 'CLASS',
6710             class => 'SOAP::WSDL::OpMessage',
6711             },
6712             output => {
6713             type => 'CLASS',
6714             class => 'SOAP::WSDL::OpMessage',
6715             },
6716             fault => {
6717             type => 'CLASS',
6718             class => 'SOAP::WSDL::OpMessage',
6719             },
6720             types => {
6721             type => 'CLASS',
6722             class => 'SOAP::WSDL::Types',
6723             },
6724             documentation => {
6725             type => 'CONTENT',
6726             method => 'set_documentation',
6727             }
6728             },
6729             # soap:
6730             'http://schemas.xmlsoap.org/wsdl/soap/' => {
6731             operation => {
6732             type => 'CLASS',
6733             class => 'SOAP::WSDL::SOAP::Operation',
6734             },
6735             binding => {
6736             type => 'PARENT',
6737             },
6738             body => {
6739             type => 'CLASS',
6740             class => 'SOAP::WSDL::SOAP::Body',
6741             },
6742             header => {
6743             type => 'CLASS',
6744             class => 'SOAP::WSDL::SOAP::Header',
6745             },
6746             address => {
6747             type => 'CLASS',
6748             class => 'SOAP::WSDL::SOAP::Address',
6749             }
6750             },
6751             'http://www.w3.org/2001/XMLSchema' => {
6752             'import' => {
6753             type => 'HANDLER',
6754             method => 'xml_schema_import',
6755             },
6756             schema => {
6757             type => 'CLASS',
6758             class => 'SOAP::WSDL::XSD::Schema',
6759             },
6760             attribute => {
6761             type => 'CLASS',
6762             class => 'SOAP::WSDL::XSD::Attribute',
6763             },
6764             attributeGroup => {
6765             type => 'CLASS',
6766             class => 'SOAP::WSDL::XSD::AttributeGroup',
6767             },
6768             key => {
6769             type => 'SKIP', # not implemented yet
6770             },
6771             keyref => {
6772             type => 'SKIP', # not implemented yet
6773             },
6774             unique => {
6775             type => 'SKIP', # not implemented yet
6776             },
6777             notation => {
6778             type => 'SKIP', # not implemented yet
6779             },
6780             annotation => {
6781             type => 'CLASS', # not implemented yet
6782             class => 'SOAP::WSDL::XSD::Annotation',
6783             },
6784             documentation => {
6785             type => 'CONTENT',
6786             method => 'set_documentation',
6787             },
6788             appinfo => {
6789             type => 'SKIP', # not implemented yet
6790             },
6791             description => {
6792             type => 'SKIP', # not implemented yet
6793             },
6794             element => {
6795             type => 'CLASS',
6796             class => 'SOAP::WSDL::XSD::Element',
6797             },
6798             simpleType => {
6799             type => 'CLASS',
6800             class => 'SOAP::WSDL::XSD::SimpleType',
6801             },
6802             complexType => {
6803             type => 'CLASS',
6804             class => 'SOAP::WSDL::XSD::ComplexType',
6805             },
6806             simpleContent => {
6807             type => 'METHOD',
6808             method => 'set_contentModel',
6809             value => 'simpleContent'
6810             },
6811             complexContent => {
6812             type => 'METHOD',
6813             method => 'set_contentModel',
6814             value => 'complexContent'
6815             },
6816             restriction => {
6817             type => 'METHOD',
6818             method => 'set_restriction',
6819             },
6820             extension => {
6821             type => 'METHOD',
6822             method => 'set_extension',
6823             },
6824             list => {
6825             type => 'METHOD',
6826             method => 'set_list',
6827             },
6828             union => {
6829             type => 'METHOD',
6830             method => 'set_union',
6831             },
6832             enumeration => {
6833             type => 'CLASS',
6834             class => 'SOAP::WSDL::XSD::Enumeration',
6835             },
6836             group => {
6837             type => 'CLASS',
6838             class => 'SOAP::WSDL::XSD::Group',
6839             },
6840             all => {
6841             type => 'METHOD',
6842             method => 'set_variety',
6843             value => 'all',
6844             },
6845             choice => {
6846             type => 'METHOD',
6847             method => 'set_variety',
6848             value => 'choice',
6849             },
6850             sequence => {
6851             type => 'METHOD',
6852             method => 'set_variety',
6853             value => 'sequence',
6854             },
6855             value => {
6856             type => 'SKIP',
6857             },
6858             minExclusive => {
6859             type => 'CLASS',
6860             class => 'SOAP::WSDL::XSD::MinExclusive',
6861             },
6862             maxExclusive => {
6863             type => 'CLASS',
6864             class => 'SOAP::WSDL::XSD::MaxExclusive',
6865             },
6866             minInclusive => {
6867             type => 'CLASS',
6868             class => 'SOAP::WSDL::XSD::MinInclusive',
6869             },
6870             maxInclusive => {
6871             type => 'CLASS',
6872             class => 'SOAP::WSDL::XSD::MaxInclusive',
6873             },
6874             maxLength => {
6875             type => 'CLASS',
6876             class => 'SOAP::WSDL::XSD::MaxLength',
6877             },
6878             minLength => {
6879             type => 'CLASS',
6880             class => 'SOAP::WSDL::XSD::MinLength',
6881             },
6882             totalDigits => {
6883             type => 'CLASS',
6884             class => 'SOAP::WSDL::XSD::TotalDigits',
6885             },
6886             fractionDigits => {
6887             type => 'CLASS',
6888             class => 'SOAP::WSDL::XSD::FractionDigits',
6889             },
6890             },
6891             );
6892            
6893             $TYPE_FROM{ 'http://www.w3.org/2000/10/XMLSchema' } = $TYPE_FROM{ 'http://www.w3.org/2001/XMLSchema' };
6894            
6895             sub lookup {
6896             my ($self, $namespace, $name) = @_;
6897             return $TYPE_FROM{ $namespace }->{ $name };
6898             }
6899            
6900             1;
6901             SOAP_WSDL_TYPELOOKUP
6902              
6903 6         12 $fatpacked{"SOAP/WSDL/Types.pm"} = <<'SOAP_WSDL_TYPES';
6904             package
6905             SOAP::WSDL::Types;
6906             use strict;
6907             use warnings;
6908             use SOAP::WSDL::XSD::Schema::Builtin;
6909             use Class::Std::Fast::Storable;
6910             use base qw(SOAP::WSDL::Base);
6911            
6912             use version; our $VERSION = qv('2.00.99_3');
6913            
6914             my %schema_of :ATTR(:name<schema> :default<[]>);
6915            
6916             sub START {
6917             my ($self, $ident, $args_of) = @_;
6918             $self->push_schema( SOAP::WSDL::XSD::Schema::Builtin->new() );
6919             return $self;
6920             }
6921            
6922             sub find_type {
6923             my ($self, $ns, $name) = @_;
6924             ($ns, $name) = @{ $ns } if ref $ns; # allow passing list refs
6925             print "Looking for type {$ns}$name\n" if ($SOAP::WSDL::Trace);
6926             foreach my $schema (@{ $schema_of{ ident $self } }) {
6927             my $type = $schema->find_type($ns, $name);
6928             return $type if $type;
6929             }
6930             return;
6931             }
6932            
6933             sub find_attribute {
6934             my ($self, $ns, $name) = @_;
6935             ($ns, $name) = @{ $ns } if ref $ns; # allow passing list refs
6936             print "Looking for attribute {$ns}$name\n" if ($SOAP::WSDL::Trace);
6937             foreach my $schema (@{ $schema_of{ ident $self } }) {
6938             my $type = $schema->find_attribute($ns, $name);
6939             return $type if $type;
6940             }
6941             return;
6942             }
6943            
6944             sub find_element {
6945             my ($self, $ns, $name) = @_;
6946             ($ns, $name) = @{ $ns } if ref $ns; # allow passing list refs
6947             print "Looking for element {$ns}$name\n" if ($SOAP::WSDL::Trace);
6948             foreach my $schema (@{ $schema_of{ ident $self } }) {
6949             print "\tin schema ", $schema->get_targetNamespace() ,"\n" if ($SOAP::WSDL::Trace);
6950             my $type = $schema->find_element($ns, $name);
6951             return $type if $type;
6952             }
6953             return;
6954             }
6955            
6956             1;
6957             SOAP_WSDL_TYPES
6958              
6959 6         12 $fatpacked{"SOAP/WSDL/XSD/Annotation.pm"} = <<'SOAP_WSDL_XSD_ANNOTATION';
6960             package
6961             SOAP::WSDL::XSD::Annotation;
6962             use strict;
6963             use warnings;
6964             use Class::Std::Fast::Storable constructor => 'none';
6965             use base qw(SOAP::WSDL::Base);
6966            
6967             use version; our $VERSION = qv('2.00.99_3');
6968            
6969             #<enumeration value="">
6970            
6971             # id provided by Base
6972             # name provided by Base
6973             # annotation provided by Base
6974            
6975             # may be defined as atomic simpleType
6976             my %appinfo_of :ATTR(:name<appinfo> :default<()>);
6977            
6978             # documentation provided by Base
6979            
6980             1;
6981             SOAP_WSDL_XSD_ANNOTATION
6982              
6983 6         11 $fatpacked{"SOAP/WSDL/XSD/Attribute.pm"} = <<'SOAP_WSDL_XSD_ATTRIBUTE';
6984             package
6985             SOAP::WSDL::XSD::Attribute;
6986             use strict;
6987             use warnings;
6988             use Class::Std::Fast::Storable constructor => 'none';
6989             use base qw(SOAP::WSDL::Base);
6990            
6991             use version; our $VERSION = qv('2.00.99_3');
6992            
6993             #<attribute
6994             # default = string
6995             # fixed = string
6996             # form = (qualified | unqualified)
6997             # id = ID
6998             # name = NCName
6999             # ref = QName
7000             # type = QName
7001             # use = (optional | prohibited | required) : optional
7002             # {any attributes with non-schema namespace . . .}>
7003             # Content: (annotation?, (simpleType?))
7004             #</attribute>
7005            
7006             # id provided by Base
7007             # name provided by Base
7008             # annotation provided by Base
7009            
7010             my %default_of :ATTR(:name<default> :default<()>);
7011             my %fixed_of :ATTR(:name<fixed> :default<()>);
7012             my %form_of :ATTR(:name<form> :default<()>);
7013            
7014             my %type_of :ATTR(:name<type> :default<()>);
7015             my %use_of :ATTR(:name<use> :default<()>);
7016             my %ref_of :ATTR(:name<ref> :default<()>);
7017            
7018             # may be defined as atomic simpleType
7019             my %simpleType_of :ATTR(:name<simpleType> :default<()>);
7020            
7021             1;
7022             SOAP_WSDL_XSD_ATTRIBUTE
7023              
7024 6         14 $fatpacked{"SOAP/WSDL/XSD/AttributeGroup.pm"} =
7025             <<'SOAP_WSDL_XSD_ATTRIBUTEGROUP';
7026             package
7027             SOAP::WSDL::XSD::AttributeGroup;
7028             use strict;
7029             use warnings;
7030             use Class::Std::Fast::Storable constructor => 'none';
7031             use base qw(SOAP::WSDL::Base);
7032            
7033             use version; our $VERSION = qv('2.00.99_3');
7034            
7035             #<attributeGroup
7036             # id = ID
7037             # name = NCName
7038             # ref = QName
7039             # {any attributes with non-schema namespace . . .}>
7040             # Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))
7041             #</attributeGroup>
7042            
7043             # id provided by Base
7044             # name provided by Base
7045             # annotation provided by Base
7046            
7047             my %ref_of :ATTR(:name<ref> :default<()>);
7048            
7049             # may be defined as atomic simpleType
7050             my %attribute_of :ATTR(:name<attribute> :default<()>);
7051             my %attributeGroup_of :ATTR(:name<attributeGroup> :default<()>);
7052            
7053             1;
7054             SOAP_WSDL_XSD_ATTRIBUTEGROUP
7055              
7056 6         14 $fatpacked{"SOAP/WSDL/XSD/Builtin.pm"} = <<'SOAP_WSDL_XSD_BUILTIN';
7057             package
7058             SOAP::WSDL::XSD::Builtin;
7059             use strict;
7060             use warnings;
7061             use Class::Std::Fast::Storable;
7062             use base qw(SOAP::WSDL::Base);
7063            
7064             use version; our $VERSION = qv('2.00.99_3');
7065            
7066             # only used in SOAP::WSDL - will be obsolete once SOAP::WSDL uses the
7067             # generative approach, too
7068            
7069             sub serialize {
7070             my ($self, $name, $value, $opt) = @_;
7071             my $xml;
7072             $opt->{ indent } ||= "";
7073             $opt->{ attributes } ||= [];
7074            
7075             $xml .= $opt->{ indent } if ($opt->{ readable });
7076             $xml .= '<' . join ' ', $name, @{ $opt->{ attributes } };
7077             if ( $opt->{ autotype }) {
7078             my $ns = $self->get_targetNamespace();
7079             my %prefix_of = reverse %{ $opt->{ namespace } };
7080             my $prefix = $prefix_of{ $ns }
7081             || die 'No prefix found for namespace '. $ns;
7082             $xml .= ' type="' . $prefix . ':'
7083             . $self->get_name() . '"';
7084             }
7085            
7086             if (defined $value) {
7087             $xml .= '>';
7088             $xml .= "$value";
7089             $xml .= '</' . $name . '>' ;
7090             }
7091             else {
7092             $xml .= '/>';
7093             }
7094             $xml .= "\n" if ($opt->{ readable });
7095             return $xml;
7096             }
7097            
7098             1;
7099             SOAP_WSDL_XSD_BUILTIN
7100              
7101 6         10 $fatpacked{"SOAP/WSDL/XSD/ComplexType.pm"} = <<'SOAP_WSDL_XSD_COMPLEXTYPE';
7102             package
7103             SOAP::WSDL::XSD::ComplexType;
7104             use strict;
7105             use warnings;
7106             use Class::Std::Fast::Storable;
7107             use Scalar::Util qw(blessed);
7108             use base qw(SOAP::WSDL::Base);
7109            
7110             use version; our $VERSION = qv('2.00.99_3');
7111            
7112             # id provided by Base
7113             # name provided by Base
7114             # annotation provided by Base
7115             my %length_of :ATTR(:name<length> :default<[]>);
7116             my %minLength_of :ATTR(:name<minLength> :default<[]>);
7117             my %maxLength_of :ATTR(:name<maxLength> :default<[]>);
7118             my %pattern_of :ATTR(:name<pattern> :default<[]>);
7119             my %enumeration_of :ATTR(:name<enumeration> :default<[]>);
7120             my %whiteSpace_of :ATTR(:name<whiteSpace> :default<[]>);
7121             my %totalDigits_of :ATTR(:name<totalDigits> :default<[]>);
7122             my %fractionDigits_of :ATTR(:name<fractionDigits> :default<[]>);
7123             my %minExclusive :ATTR(:name<minExclusive> :default<[]>);
7124             my %minInclusive :ATTR(:name<minInclusive> :default<[]>);
7125             my %maxExclusive :ATTR(:name<maxExclusive> :default<[]>);
7126             my %maxInclusive :ATTR(:name<maxInclusive> :default<[]>);
7127            
7128            
7129             my %attribute_of :ATTR(:name<attribute> :default<()>);
7130             my %element_of :ATTR(:name<element> :default<[]>);
7131             my %group_of :ATTR(:name<group> :default<()>);
7132             my %variety_of :ATTR(:name<variety> :default<()>);
7133             my %base_of :ATTR(:name<base> :default<()>);
7134             my %itemType_of :ATTR(:name<itemType> :default<()>);
7135             my %abstract_of :ATTR(:name<abstract> :default<()>);
7136             my %final_of :ATTR(:name<final> :default<()>);
7137             my %mixed_of :ATTR(:name<mixed> :default<()>); # default is false
7138            
7139             my %derivation_of :ATTR(:name<derivation> :default<()>);
7140            
7141             # is set to simpleContent/complexContent
7142             my %content_model_of :ATTR(:name<contentModel> :default<NONE>);
7143            
7144             sub get_flavor; *get_flavor = \&get_variety;
7145            
7146             sub push_element {
7147             my $self = shift;
7148             my $element = shift;
7149             if ($variety_of{ ident $self } eq 'all')
7150             {
7151             $element->set_minOccurs(0) if not defined ($element->get_minOccurs);
7152             $element->set_maxOccurs(1) if not defined ($element->get_maxOccurs);
7153             }
7154             elsif ($variety_of{ ident $self } eq 'sequence')
7155             {
7156             $element->set_minOccurs(1) if not defined ($element->get_minOccurs);
7157             $element->set_maxOccurs(1) if not defined ($element->get_maxOccurs);
7158             }
7159             push @{ $element_of{ ident $self } }, $element;
7160             }
7161            
7162             sub set_restriction {
7163             my $self = shift;
7164             my $element = shift;
7165             $variety_of{ ident $self } = 'restriction';
7166             $derivation_of{ ident $self } = 'restriction';
7167             $base_of{ ident $self } = $element->{ Value };
7168             }
7169            
7170             sub set_extension {
7171             my $self = shift;
7172             my $element = shift;
7173             $variety_of{ ident $self } = 'extension';
7174             $derivation_of{ ident $self } = 'extension';
7175             $base_of{ ident $self } = $element->{ Value };
7176             }
7177            
7178             sub init {
7179             my $self = shift;
7180             my @args = @_;
7181             $self->SUPER::init( @args );
7182             }
7183            
7184             sub serialize {
7185             my ($self, $name, $value, $opt) = @_;
7186            
7187             $opt->{ indent } ||= q{};
7188             $opt->{ attributes } ||= [];
7189             my $variety = $self->get_variety();
7190             my $xml = ($opt->{ readable }) ? $opt->{ indent } : q{}; # add indentation
7191            
7192             if ( $opt->{ qualify } ) {
7193             $opt->{ attributes } = [ ' xmlns="' . $self->get_targetNamespace .'"' ];
7194             delete $opt->{ qualify };
7195             }
7196            
7197             $xml .= join q{ } , "<$name" , @{ $opt->{ attributes } };
7198             delete $opt->{ attributes }; # don't propagate...
7199            
7200             if ( $opt->{ autotype }) {
7201             my $ns = $self->get_targetNamespace();
7202             # reverse namespace by prefix hash
7203             my %prefix_of = reverse %{ $opt->{ namespace } };
7204             my $prefix = $prefix_of{ $ns }
7205             || die 'No prefix found for namespace '. $ns;
7206             $xml .= join q{}, " type=\"$prefix:", $self->get_name(), '" '
7207             if ($self->get_name() );
7208             }
7209             $xml .= '>';
7210             $xml .= "\n" if ( $opt->{ readable } ); # add linebreak
7211            
7212             if ($self->schema) {
7213             if ($self->schema()->get_elementFormDefault() ne "qualified") {
7214             push @{$opt->{ attributes } }, q{xmlns=""}
7215             if ($self->get_targetNamespace() ne "");
7216             }
7217             }
7218             if ( ($variety eq "sequence") or ($variety eq "all") ) {
7219             $opt->{ indent } .= "\t";
7220             for my $element (@{ $self->get_element() }) {
7221             # resolve element ref
7222             #
7223             # Basic algorithm is like this:
7224             # If on serialization, we meet a element whose get_ref method
7225             # returns a true value, lookup the element from the <types>
7226             # definitions instead, and serialize this element.
7227             #
7228             if (my $ref = $element->get_ref()) {
7229             $element = $opt->{ typelib }->find_element(
7230             $element->expand($ref)
7231             );
7232             }
7233            
7234             # might be list - listify
7235             $value = [ $value ] if not ref $value eq 'ARRAY';
7236            
7237             for my $single_value (@{ $value }) {
7238             my $element_value;
7239             if (blessed $single_value) {
7240             my $method = 'get_' . $element->get_name();
7241             $element_value = $single_value->$method();
7242             }
7243             else {
7244             $element_value = $single_value->{ $element->get_name() };
7245             }
7246             $element_value = [ $element_value ]
7247             if not ref $element_value eq 'ARRAY';
7248            
7249             $xml .= join q{}
7250             , map { $element->serialize( undef, $_, $opt ) }
7251             @{ $element_value };
7252             }
7253             }
7254             $opt->{ indent } =~s/\t$//;
7255             }
7256             else {
7257             die "sorry, we just handle all and sequence types yet...";
7258             }
7259             $xml .= $opt->{ indent } if ( $opt->{ readable } ); # add indentation
7260             $xml .= '</' . $name . '>';
7261             $xml .= "\n" if ($opt->{ readable } ); # add linebreak
7262             return $xml;
7263             }
7264            
7265             1;
7266            
7267             SOAP_WSDL_XSD_COMPLEXTYPE
7268              
7269 6         12 $fatpacked{"SOAP/WSDL/XSD/Element.pm"} = <<'SOAP_WSDL_XSD_ELEMENT';
7270             package
7271             SOAP::WSDL::XSD::Element;
7272             use strict;
7273             use warnings;
7274             use Class::Std::Fast::Storable;
7275             use base qw(SOAP::WSDL::Base);
7276            
7277             use version; our $VERSION = qv('2.00.99_3');
7278            
7279             # id provided by Base
7280             # name provided by Base
7281             # annotation provided by Base
7282             my %simpleType_of :ATTR(:name<simpleType> :default<()>);
7283             my %complexType_of :ATTR(:name<complexType> :default<()>);
7284             my %facet_of :ATTR(:name<facet> :default<()>);
7285             my %type_of :ATTR(:name<type> :default<()>);
7286             my %abstract_of :ATTR(:name<abstract> :default<()>);
7287             my %block_of :ATTR(:name<block> :default<()>);
7288             my %default_of :ATTR(:name<default> :default<()>);
7289             my %final_of :ATTR(:name<final> :default<()>);
7290             my %fixed_of :ATTR(:name<fixed> :default<()>);
7291             my %form_of :ATTR(:name<form> :default<()>);
7292             my %maxOccurs_of :ATTR(:name<maxOccurs> :default<()>);
7293             my %minOccurs_of :ATTR(:name<minOccurs> :default<()>);
7294             my %nillable_of :ATTR(:name<nillable> :default<()>);
7295             my %ref_of :ATTR(:name<ref> :default<()>);
7296             my %substitutionGroup_of :ATTR(:name<substitutionGroup> :default<()>);
7297            
7298             sub first_simpleType {
7299             my $result_ref = $simpleType_of{ ident shift };
7300             return if not $result_ref;
7301             return $result_ref if (not ref $result_ref eq 'ARRAY');
7302             return $result_ref->[0];
7303             }
7304            
7305             sub first_complexType {
7306             my $result_ref = $complexType_of{ ident shift };
7307             return if not $result_ref;
7308             return $result_ref if (not ref $result_ref eq 'ARRAY');
7309             return $result_ref->[0];
7310             }
7311            
7312             # serialize type instead...
7313             sub serialize {
7314             my ($self, $name, $value, $opt) = @_;
7315             my $type;
7316             my $typelib = $opt->{ typelib };
7317             my %ns_map = %{ $opt->{ namespace } };
7318             my $ident = ident $self;
7319            
7320             # abstract elements may only be serialized via ref - and then we have a
7321             # name...
7322             die "cannot serialize abstract element" if $abstract_of{ $ident }
7323             and not $name;
7324            
7325             # TODO: implement final and substitutionGroup - maybe never implement
7326             # substitutionGroup ?
7327            
7328             $name = $self->get_name() if not ($name);
7329            
7330             if ( $opt->{ qualify } ) {
7331             $opt->{ attributes } = [ ' xmlns="' . $self->get_targetNamespace .'"' ];
7332             }
7333            
7334            
7335             # set default and fixed - fixed overrides everything,
7336             # default only empty (undefined) values
7337             if (not defined $value) {
7338             $value = $default_of{ ident $self } if $default_of{ ident $self };
7339             }
7340             $value = $fixed_of{ ident $self } if $fixed_of{ ident $self };
7341            
7342             # TODO check nillable and serialize empty data correctly
7343            
7344             # return if minOccurs is 0 and we have no value
7345             if (defined $minOccurs_of{ ident $self }
7346             and $minOccurs_of{ ident $self } == 0) {
7347             return q{} if not defined $value;
7348             }
7349            
7350             # handle direct simpleType and complexType here
7351             if ($type = $self->first_simpleType() ) { # simpleType
7352             return $type->serialize( $name, $value, $opt );
7353             }
7354             elsif ($type = $self->first_complexType() ) { # complexType
7355             return $type->serialize( $name, $value, $opt );
7356             }
7357             elsif (my $ref_name = $ref_of{ $ident }) { # ref
7358             my ($prefix, $localname) = split /:/ , $ref_name;
7359             my $ns = $ns_map{ $prefix };
7360             $type = $typelib->find_element( $ns, $localname );
7361             die "no element for ref $prefix:$localname" if (not $type);
7362             return $type->serialize( $name, $value, $opt );
7363             }
7364            
7365             # lookup type
7366             my ($prefix, $localname) = split /:/ , $self->get_type();
7367             my $ns = $ns_map{ $prefix };
7368             $type = $typelib->find_type(
7369             $ns, $localname
7370             );
7371            
7372             # safety check
7373             die "no type for $prefix:$localname $ns_map{$prefix}" if (not $type);
7374            
7375             return $type->serialize( $name, $value, $opt );
7376             }
7377            
7378             1;
7379            
7380             SOAP_WSDL_XSD_ELEMENT
7381              
7382 6         16 $fatpacked{"SOAP/WSDL/XSD/Enumeration.pm"} = <<'SOAP_WSDL_XSD_ENUMERATION';
7383             package
7384             SOAP::WSDL::XSD::Enumeration;
7385             use strict;
7386             use warnings;
7387             use Class::Std::Fast::Storable constructor => 'none';
7388             use base qw(SOAP::WSDL::Base);
7389            
7390             use version; our $VERSION = qv('2.00.99_3');
7391            
7392             #<enumeration value="">
7393            
7394             # id provided by Base
7395             # name provided by Base
7396             # annotation provided by Base
7397            
7398             # may be defined as atomic simpleType
7399             my %value_of :ATTR(:name<value> :default<()>);
7400            
7401             1;
7402             SOAP_WSDL_XSD_ENUMERATION
7403              
7404 6         16 $fatpacked{"SOAP/WSDL/XSD/FractionDigits.pm"} =
7405             <<'SOAP_WSDL_XSD_FRACTIONDIGITS';
7406             package
7407             SOAP::WSDL::XSD::FractionDigits;
7408             use strict;
7409             use warnings;
7410             use Class::Std::Fast::Storable constructor => 'none';
7411             use base qw(SOAP::WSDL::Base);
7412            
7413             use version; our $VERSION = qv('2.00.99_3');
7414             #<pattern value="">
7415            
7416             # id provided by Base
7417             # name provided by Base
7418             # annotation provided by Base
7419            
7420             # may be defined as atomic simpleType
7421             my %value_of :ATTR(:name<value> :default<()>);
7422            
7423             1;
7424             SOAP_WSDL_XSD_FRACTIONDIGITS
7425              
7426 6         12 $fatpacked{"SOAP/WSDL/XSD/Group.pm"} = <<'SOAP_WSDL_XSD_GROUP';
7427             package
7428             SOAP::WSDL::XSD::Group;
7429             use strict;
7430             use warnings;
7431             use Class::Std::Fast::Storable constructor => 'none';
7432             use base qw(SOAP::WSDL::Base);
7433            
7434             use version; our $VERSION = qv('2.00.99_3');
7435            
7436             #<xs:group name="myModelGroup">
7437             # <xs:sequence>
7438             # <xs:element ref="someThing"/>
7439             # . . .
7440             # </xs:sequence>
7441             #</xs:group>
7442             #
7443             #<xs:complexType name="trivial">
7444             # <xs:group ref="myModelGroup"/>
7445             # <xs:attribute .../>
7446             #</xs:complexType>
7447             #
7448             #<xs:complexType name="moreSo">
7449             # <xs:choice>
7450             # <xs:element ref="anotherThing"/>
7451             # <xs:group ref="myModelGroup"/>
7452             # </xs:choice>
7453             # <xs:attribute .../>
7454             #</xs:complexType>
7455            
7456             my %ref_of :ATTR(:name<ref> :default<()>);
7457            
7458             my %maxOccurs_of :ATTR(:name<maxOccurs> :default<()>);
7459             my %minOccurs_of :ATTR(:name<minOccurs> :default<()>);
7460             my %annotation_of :ATTR(:name<annotation> :default<()>);
7461             my %element_of :ATTR(:name<element> :default<()>);
7462             my %group_of :ATTR(:name<group> :default<()>);
7463             my %variety_of :ATTR(:name<variety> :default<()>);
7464            
7465             1;
7466             SOAP_WSDL_XSD_GROUP
7467              
7468 6         16 $fatpacked{"SOAP/WSDL/XSD/Length.pm"} = <<'SOAP_WSDL_XSD_LENGTH';
7469             package
7470             SOAP::WSDL::XSD::Length;
7471             use strict;
7472             use warnings;
7473             use Class::Std::Fast::Storable constructor => 'none';
7474             use base qw(SOAP::WSDL::Base);
7475            
7476             use version; our $VERSION = qv('2.00.99_3');
7477            
7478             #<minExclusive value="">
7479            
7480             # id provided by Base
7481             # name provided by Base
7482             # annotation provided by Base
7483            
7484             # may be defined as atomic simpleType
7485             my %value_of :ATTR(:name<value> :default<()>);
7486            
7487             1;
7488             SOAP_WSDL_XSD_LENGTH
7489              
7490 6         31 $fatpacked{"SOAP/WSDL/XSD/MaxExclusive.pm"} =
7491             <<'SOAP_WSDL_XSD_MAXEXCLUSIVE';
7492             package
7493             SOAP::WSDL::XSD::MaxExclusive;
7494             use strict;
7495             use warnings;
7496             use Class::Std::Fast::Storable constructor => 'none';
7497             use base qw(SOAP::WSDL::Base);
7498            
7499             use version; our $VERSION = qv('2.00.99_3');
7500            
7501             #<minExclusive value="">
7502            
7503             # id provided by Base
7504             # name provided by Base
7505             # annotation provided by Base
7506            
7507             # may be defined as atomic simpleType
7508             my %value_of :ATTR(:name<value> :default<()>);
7509            
7510             1;
7511             SOAP_WSDL_XSD_MAXEXCLUSIVE
7512              
7513 6         13 $fatpacked{"SOAP/WSDL/XSD/MaxInclusive.pm"} =
7514             <<'SOAP_WSDL_XSD_MAXINCLUSIVE';
7515             package
7516             SOAP::WSDL::XSD::MaxInclusive;
7517             use strict;
7518             use warnings;
7519             use Class::Std::Fast::Storable constructor => 'none';
7520             use base qw(SOAP::WSDL::Base);
7521            
7522             use version; our $VERSION = qv('2.00.99_3');
7523            
7524             #<minExclusive value="">
7525            
7526             # id provided by Base
7527             # name provided by Base
7528             # annotation provided by Base
7529            
7530             # may be defined as atomic simpleType
7531             my %value_of :ATTR(:name<value> :default<()>);
7532            
7533             1;
7534             SOAP_WSDL_XSD_MAXINCLUSIVE
7535              
7536 6         14 $fatpacked{"SOAP/WSDL/XSD/MaxLength.pm"} = <<'SOAP_WSDL_XSD_MAXLENGTH';
7537             package
7538             SOAP::WSDL::XSD::MaxLength;
7539             use strict;
7540             use warnings;
7541             use Class::Std::Fast::Storable constructor => 'none';
7542             use base qw(SOAP::WSDL::Base);
7543            
7544             use version; our $VERSION = qv('2.00.99_3');
7545            
7546             #<maxLength value="">
7547            
7548             # id provided by Base
7549             # name provided by Base
7550             # annotation provided by Base
7551            
7552             # may be defined as atomic simpleType
7553             my %value_of :ATTR(:name<value> :default<()>);
7554             my %fixed_of :ATTR(:name<fixed> :default<()>);
7555            
7556             1;
7557             SOAP_WSDL_XSD_MAXLENGTH
7558              
7559 6         12 $fatpacked{"SOAP/WSDL/XSD/MinExclusive.pm"} =
7560             <<'SOAP_WSDL_XSD_MINEXCLUSIVE';
7561             package
7562             SOAP::WSDL::XSD::MinExclusive;
7563             use strict;
7564             use warnings;
7565             use Class::Std::Fast::Storable constructor => 'none';
7566             use base qw(SOAP::WSDL::Base);
7567            
7568             use version; our $VERSION = qv('2.00.99_3');
7569            
7570             #<minExclusive value="">
7571            
7572             # id provided by Base
7573             # name provided by Base
7574             # annotation provided by Base
7575            
7576             # may be defined as atomic simpleType
7577             my %value_of :ATTR(:name<value> :default<()>);
7578            
7579             1;
7580             SOAP_WSDL_XSD_MINEXCLUSIVE
7581              
7582 6         13 $fatpacked{"SOAP/WSDL/XSD/MinInclusive.pm"} =
7583             <<'SOAP_WSDL_XSD_MININCLUSIVE';
7584             package
7585             SOAP::WSDL::XSD::MinInclusive;
7586             use strict;
7587             use warnings;
7588             use Class::Std::Fast::Storable constructor => 'none';
7589             use base qw(SOAP::WSDL::Base);
7590            
7591             use version; our $VERSION = qv('2.00.99_3');
7592            
7593             #<minExclusive value="">
7594            
7595             # id provided by Base
7596             # name provided by Base
7597             # annotation provided by Base
7598            
7599             # may be defined as atomic simpleType
7600             my %value_of :ATTR(:name<value> :default<()>);
7601            
7602             1;
7603             SOAP_WSDL_XSD_MININCLUSIVE
7604              
7605 6         19 $fatpacked{"SOAP/WSDL/XSD/MinLength.pm"} = <<'SOAP_WSDL_XSD_MINLENGTH';
7606             package
7607             SOAP::WSDL::XSD::MinLength;
7608             use strict;
7609             use warnings;
7610             use Class::Std::Fast::Storable constructor => 'none';
7611             use base qw(SOAP::WSDL::Base);
7612            
7613             use version; our $VERSION = qv('2.00.99_3');
7614            
7615             #<minExclusive value="">
7616            
7617             # id provided by Base
7618             # name provided by Base
7619             # annotation provided by Base
7620            
7621             # may be defined as atomic simpleType
7622             my %value_of :ATTR(:name<value> :default<()>);
7623            
7624             1;
7625             SOAP_WSDL_XSD_MINLENGTH
7626              
7627 6         13 $fatpacked{"SOAP/WSDL/XSD/Pattern.pm"} = <<'SOAP_WSDL_XSD_PATTERN';
7628             package
7629             SOAP::WSDL::XSD::Pattern;
7630             use strict;
7631             use warnings;
7632             use Class::Std::Fast::Storable constructor => 'none';
7633             use base qw(SOAP::WSDL::Base);
7634            
7635             use version; our $VERSION = qv('2.00.99_3');
7636            
7637             #<pattern value="">
7638            
7639             # id provided by Base
7640             # name provided by Base
7641             # annotation provided by Base
7642            
7643             # may be defined as atomic simpleType
7644             my %value_of :ATTR(:name<value> :default<()>);
7645            
7646             1;
7647             SOAP_WSDL_XSD_PATTERN
7648              
7649 6         13 $fatpacked{"SOAP/WSDL/XSD/Schema.pm"} = <<'SOAP_WSDL_XSD_SCHEMA';
7650             package
7651             SOAP::WSDL::XSD::Schema;
7652             use strict;
7653             use warnings;
7654             use Class::Std::Fast::Storable;
7655             use base qw(SOAP::WSDL::Base);
7656            
7657             use version; our $VERSION = qv('2.00.99_3');
7658            
7659             # child elements
7660             my %attributeGroup_of :ATTR(:name<attributeGroup> :default<[]>);
7661             my %attribute_of :ATTR(:name<attribute> :default<[]>);
7662             my %element_of :ATTR(:name<element> :default<[]>);
7663             my %group_of :ATTR(:name<group> :default<[]>);
7664             my %type_of :ATTR(:name<type> :default<[]>);
7665            
7666             # attributes
7667             my %attributeFormDefault_of :ATTR(:name<attributeFormDefault> :default<unqualified>);
7668             my %blockDefault_of :ATTR(:name<blockDefault> :default<()>);
7669             my %elementFormDefault_of :ATTR(:name<elementFormDefault> :default<unqualified>);
7670             my %finalDefault_of :ATTR(:name<finalDefault> :default<()>);
7671             my %version_of :ATTR(:name<version> :default<()>);
7672            
7673             # id
7674             # name
7675             # targetNamespace inherited from Base
7676             # xmlns
7677            
7678             #
7679             # attributeFormDefault = (qualified | unqualified) : unqualified
7680             # blockDefault = (#all | List of (extension | restriction | substitution)) : ''
7681             # elementFormDefault = (qualified | unqualified) : unqualified
7682             # finalDefault = (#all | List of (extension | restriction | list | union)) : ''
7683             # id = ID
7684             # targetNamespace = anyURI
7685             # version = token
7686             # xml:lang = language
7687             #
7688             #
7689             # alias type with all variants
7690             # AUTOMETHOD is WAY too slow..
7691             {
7692             no strict qw(refs);
7693             for my $name (qw(simpleType complexType) ) {
7694             *{ "set_$name" } = \&set_type;
7695             *{ "get_$name" } = \&get_type;
7696             *{ "push_$name" } = \&push_type;
7697             *{ "find_$name" } = \&find_type;
7698             }
7699             }
7700            
7701             sub push_type {
7702             # use $_[n] for performance -
7703             # we're called on each and every type inside WSDL
7704             push @{ $type_of{ ident $_[0]} }, $_[1];
7705             }
7706            
7707             sub find_element {
7708             my ($self, @args) = @_;
7709             print "Looking for element $args[1] in ", $self->get_targetNamespace(), "\n" if $SOAP::WSDL::Trace;
7710             for (@{ $element_of{ ident $self } }) {
7711             print "\t{" . $_->get_targetNamespace() . "}" . $_->get_name()."\n" if $SOAP::WSDL::Trace;
7712             next if $_->get_targetNamespace() ne $args[0];
7713             return $_ if $_->get_name() eq $args[1];
7714             }
7715             return;
7716             }
7717            
7718             sub find_type {
7719             my ($self, @args) = @_;
7720             print "Looking for type $args[1] in ", $self->get_targetNamespace(), "\n" if $SOAP::WSDL::Trace;
7721             for (@{ $type_of{ ident $self } }) {
7722             print "\t{" . $_->get_targetNamespace() . "}" . $_->get_name()."\n" if $SOAP::WSDL::Trace;
7723             next if $_->get_targetNamespace() ne $args[0];
7724             return $_ if $_->get_name() eq $args[1];
7725             }
7726             return;
7727             }
7728            
7729             1;
7730             SOAP_WSDL_XSD_SCHEMA
7731              
7732 6         15 $fatpacked{"SOAP/WSDL/XSD/Schema/Builtin.pm"} =
7733             <<'SOAP_WSDL_XSD_SCHEMA_BUILTIN';
7734             package
7735             SOAP::WSDL::XSD::Schema::Builtin;
7736             use strict;
7737             use warnings;
7738             use Class::Std::Fast::Storable;
7739             use SOAP::WSDL::XSD::Schema;
7740             use SOAP::WSDL::XSD::Builtin;
7741             use base qw(SOAP::WSDL::XSD::Schema);
7742            
7743             use version; our $VERSION = qv('2.00.99_3');
7744            
7745             # all builtin types - add validation (e.g. content restrictions) later...
7746             my %BUILTINS = (
7747             'anyType' => {},
7748             'anySimpleType' => {},
7749             'anyURI' => {},
7750             'boolean' => {},
7751             'base64Binary' => {},
7752             'byte' => {},
7753             'date' => {},
7754             'dateTime' => {},
7755             'decimal' => {},
7756             'double' => {},
7757             'duration' => {},
7758             'ENTITY' => {},
7759             'float' => {},
7760             'gDay' => {},
7761             'gMonth' => {},
7762             'gMonthDay' => {},
7763             'gYearMonth' => {},
7764             'gYear' => {},
7765             'hexBinary' => {},
7766             'ID' => {},
7767             'IDREF' => {},
7768             'IDREFS' => {},
7769             'int' => {},
7770             'integer' => {},
7771             'language' => {},
7772             'long' => {},
7773             'negativeInteger' => {},
7774             'nonPositiveInteger' => {},
7775             'nonNegativeInteger' => {},
7776             'normalizedString' => {},
7777             'Name' => {},
7778             'NCName' => {},
7779             'NMTOKEN' => {},
7780             'NOTATION' => {},
7781             'positiveInteger' => {},
7782             'QName' => {},
7783             'short' => {},
7784             'string' => {},
7785             'time' => {},
7786             'token' => {},
7787             'unsignedByte' => {},
7788             'unsignedInt' => {},
7789             'unsignedLong' => {},
7790             'unsignedShort' => {},
7791             );
7792            
7793             sub START {
7794             my $self = shift;
7795             my @args = @_;
7796            
7797             while (my ($name, $value) = each %BUILTINS )
7798             {
7799             $self->push_type( SOAP::WSDL::XSD::Builtin->new({
7800             name => $name,
7801             targetNamespace => 'http://www.w3.org/2001/XMLSchema',
7802             xmlns => {
7803             '#default' => 'http://www.w3.org/2001/XMLSchema',
7804             }
7805             } )
7806             );
7807             }
7808             $self->set_targetNamespace('http://www.w3.org/2001/XMLSchema');
7809             return $self;
7810             }
7811            
7812             1;
7813            
7814            
7815             =pod
7816            
7817             =head1 NAME
7818            
7819             SOAP:WSDL::XSD::Schema::Builtin - Provides builtin XML Schema datatypes for parsing WSDL
7820            
7821             =head1 DESCRIPTION
7822            
7823             Used internally by SOAP::WSDL's WSDL parser.
7824            
7825             See <SOAP::WSDL::XSD::Typelib::Builtin|SOAP::WSDL::XSD::Typelib::Builtin> for
7826             SOAP::WSDL::XSD's builtin XML Schema datatypes.
7827            
7828             =head1 LICENSE AND COPYRIGHT
7829            
7830             Copyright (c) 2007 Martin Kutter. All rights reserved.
7831            
7832             This file is part of SOAP-WSDL. You may distribute/modify it under
7833             the same terms as perl itself
7834            
7835             =head1 AUTHOR
7836            
7837             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
7838            
7839             =head1 REPOSITORY INFORMATION
7840            
7841             $Rev: 861 $
7842             $LastChangedBy: kutterma $
7843             $Id: Builtin.pm 861 2010-03-28 10:41:26Z kutterma $
7844             $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/lib/SOAP/WSDL/XSD/Schema/Builtin.pm $
7845            
7846             =cut
7847            
7848             SOAP_WSDL_XSD_SCHEMA_BUILTIN
7849              
7850 6         13 $fatpacked{"SOAP/WSDL/XSD/SimpleType.pm"} = <<'SOAP_WSDL_XSD_SIMPLETYPE';
7851             package
7852             SOAP::WSDL::XSD::SimpleType;
7853             use strict;
7854             use warnings;
7855             use Class::Std::Fast::Storable;
7856             use base qw(SOAP::WSDL::Base);
7857            
7858             use version; our $VERSION = qv('2.00.99_3');
7859            
7860             my %length_of :ATTR(:name<length> :default<[]>);
7861             my %minLength_of :ATTR(:name<minLength> :default<[]>);
7862             my %maxLength_of :ATTR(:name<maxLength> :default<[]>);
7863             my %pattern_of :ATTR(:name<pattern> :default<[]>);
7864             my %enumeration_of :ATTR(:name<enumeration> :default<[]>);
7865             my %whiteSpace_of :ATTR(:name<whiteSpace> :default<[]>);
7866             my %totalDigits_of :ATTR(:name<totalDigits> :default<[]>);
7867             my %fractionDigits_of :ATTR(:name<fractionDigits> :default<[]>);
7868             my %minExclusive :ATTR(:name<minExclusive> :default<[]>);
7869             my %minInclusive :ATTR(:name<minInclusive> :default<[]>);
7870             my %maxExclusive :ATTR(:name<maxExclusive> :default<[]>);
7871             my %maxInclusive :ATTR(:name<maxInclusive> :default<[]>);
7872            
7873             my %nillable_of :ATTR(:name<nillable> :default<()>);
7874             my %fixed :ATTR(:name<fixed> :default<[]>);
7875            
7876             my %annotation_of :ATTR(:name<annotation> :default<()>);
7877             my %base_of :ATTR(:name<base> :default<()>);
7878             my %itemType_of :ATTR(:name<itemType> :default<()>);
7879            
7880            
7881             # TODO rename flavor to variety to be consistent with the XML Schema
7882             # specs - though flavor is the cooler name..
7883             # set to restriction|list|union|enumeration
7884             my %flavor_of :ATTR(:name<flavor> :default<()>);
7885            
7886             # for simpleType containing atomic simple types
7887             my %type_of :ATTR(:name<type> :default<()>);
7888            
7889             sub get_simpleType; *get_simpleType = \&get_type;
7890             sub set_simpleType; *set_simpleType = \&set_type;
7891            
7892             sub get_variety; *get_variety = \&get_flavor;
7893            
7894             sub set_restriction {
7895             my $self = shift;
7896             my @attributes = @_;
7897             $self->set_flavor( 'restriction' );
7898            
7899             for (@attributes) {
7900             next if (not $_->{ LocalName } eq 'base');
7901             $self->set_base( $_->{ Value } );
7902             }
7903             }
7904            
7905             sub set_list {
7906             my $self = shift;
7907             my @attributes = @_;
7908             $self->set_flavor( 'list' );
7909             for (@attributes) {
7910             next if (not $_->{ LocalName } eq 'itemType');
7911             $self->set_itemType( $_->{ Value } );
7912             }
7913             }
7914            
7915             sub set_union {
7916             my $self = shift;
7917             my @attributes = @_;
7918             $self->set_flavor( 'union' );
7919             for (@attributes) {
7920             next if (not $_->{ LocalName } eq 'memberTypes');
7921             $self->set_base( [ split /\s/, $_->{ Value } ] );
7922             }
7923             }
7924            
7925             sub serialize {
7926             my $self = shift;
7927             my $name = shift;
7928             my $value = shift;
7929             my $opt = shift;
7930             my $ident = ident $self;
7931            
7932             $opt->{ attributes } ||= [];
7933             $opt->{ indent } ||= q{};
7934            
7935             return $self->_serialize_single($name, $value , $opt)
7936             if ( $flavor_of{ $ident } eq 'restriction'
7937             or $flavor_of{ $ident } eq 'union'
7938             or $flavor_of{ $ident } eq 'enumeration');
7939            
7940             if ($flavor_of{ $ident } eq 'list' )
7941             {
7942             $value ||= [];
7943             $value = [ $value ] if ( ref( $value) ne 'ARRAY' );
7944             return $self->_serialize_single($name, join( q{ }, @{ $value } ), $opt);
7945             }
7946             }
7947            
7948             sub _serialize_single {
7949             my ($self, $name, $value, $opt) = @_;
7950             my $xml = '';
7951             $xml .= $opt->{ indent } if ($opt->{ readable }); # add indentation
7952             $xml .= '<' . join ' ', $name, @{ $opt->{ attributes } };
7953             if ( $opt->{ autotype }) {
7954             # reverse namespace by prefix hash
7955             my %prefix_of = reverse %{ $opt->{ namespace } };
7956             my $ns = $self->get_targetNamespace();
7957             my $prefix = $prefix_of{ $ns }
7958             || die 'No prefix found for namespace '. $ns;
7959             $xml .= ' type="' . $prefix . ':' . $self->get_name() .'"';
7960             }
7961            
7962             # nillabel ?
7963             return $xml .'/>' if not defined $value;
7964            
7965             $xml .= join q{}, '>' , $value , '</' , $name , '>';
7966             $xml .= "\n" if ($opt->{ readable });
7967             return $xml;
7968             }
7969            
7970             1;
7971             SOAP_WSDL_XSD_SIMPLETYPE
7972              
7973 6         16 $fatpacked{"SOAP/WSDL/XSD/TotalDigits.pm"} = <<'SOAP_WSDL_XSD_TOTALDIGITS';
7974             package
7975             SOAP::WSDL::XSD::TotalDigits;
7976             use strict;
7977             use warnings;
7978             use Class::Std::Fast::Storable constructor => 'none';
7979             use base qw(SOAP::WSDL::Base);
7980            
7981             use version; our $VERSION = qv('2.00.99_3');
7982            
7983             #<totalDigits value="">
7984            
7985             # id provided by Base
7986             # name provided by Base
7987             # annotation provided by Base
7988            
7989             # may be defined as atomic simpleType
7990             my %value_of :ATTR(:name<value> :default<()>);
7991             my %fixed_of :ATTR(:name<fixed> :default<()>);
7992             1;
7993             SOAP_WSDL_XSD_TOTALDIGITS
7994              
7995 6         12 $fatpacked{"SOAP/WSDL/XSD/Typelib/Attribute.pm"} =
7996             <<'SOAP_WSDL_XSD_TYPELIB_ATTRIBUTE';
7997             package
7998             SOAP::WSDL::XSD::Typelib::Attribute;
7999             use strict;
8000             use warnings;
8001            
8002             use base qw(SOAP::WSDL::XSD::Typelib::Element);
8003            
8004             use version; our $VERSION = qv('2.00.99_3');
8005            
8006             sub start_tag {
8007             # my ($self, $opt, $value) = @_;
8008             return q{} if (@_ < 3);
8009             my $ns = $_[0]->get_xmlns();
8010             if ($ns eq 'http://www.w3.org/XML/1998/namespace') {
8011             return qq{ xml:$_[1]->{ name }="};
8012             }
8013             return qq{ $_[1]->{ name }="};
8014             }
8015            
8016             sub end_tag {
8017             return q{"};
8018             }
8019            
8020             1;
8021             SOAP_WSDL_XSD_TYPELIB_ATTRIBUTE
8022              
8023 6         14 $fatpacked{"SOAP/WSDL/XSD/Typelib/AttributeSet.pm"} =
8024             <<'SOAP_WSDL_XSD_TYPELIB_ATTRIBUTESET';
8025             package
8026             SOAP::WSDL::XSD::Typelib::AttributeSet;
8027             use strict;
8028             use warnings;
8029             use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
8030            
8031             use version; our $VERSION = qv('2.00.99_3');
8032            
8033             sub serialize {
8034             # we work on @_ for performance.
8035             # $_[1] ||= {}; # $option_ref
8036             # TODO: What about namespaces?
8037             return ${ $_[0]->_serialize({ attr => 1 }) };
8038             }
8039            
8040            
8041             1;
8042             SOAP_WSDL_XSD_TYPELIB_ATTRIBUTESET
8043              
8044 6         13 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin.pm"} =
8045             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN';
8046             package
8047             SOAP::WSDL::XSD::Typelib::Builtin;
8048             use strict;
8049             use warnings;
8050             use Class::Std::Fast::Storable;
8051            
8052             use version; our $VERSION = qv('2.00.99_3');
8053            
8054             use SOAP::WSDL::XSD::Typelib::Builtin::anyType;
8055             use SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType;
8056             use SOAP::WSDL::XSD::Typelib::Builtin::anyURI;
8057             use SOAP::WSDL::XSD::Typelib::Builtin::base64Binary;
8058             use SOAP::WSDL::XSD::Typelib::Builtin::boolean;
8059             use SOAP::WSDL::XSD::Typelib::Builtin::byte;
8060             use SOAP::WSDL::XSD::Typelib::Builtin::date;
8061             use SOAP::WSDL::XSD::Typelib::Builtin::dateTime;
8062             use SOAP::WSDL::XSD::Typelib::Builtin::decimal;
8063             use SOAP::WSDL::XSD::Typelib::Builtin::double;
8064             use SOAP::WSDL::XSD::Typelib::Builtin::duration;
8065             use SOAP::WSDL::XSD::Typelib::Builtin::ENTITY;
8066             use SOAP::WSDL::XSD::Typelib::Builtin::float;
8067             use SOAP::WSDL::XSD::Typelib::Builtin::gDay;
8068             use SOAP::WSDL::XSD::Typelib::Builtin::gMonth;
8069             use SOAP::WSDL::XSD::Typelib::Builtin::gMonthDay;
8070             use SOAP::WSDL::XSD::Typelib::Builtin::gYear;
8071             use SOAP::WSDL::XSD::Typelib::Builtin::gYearMonth;
8072             use SOAP::WSDL::XSD::Typelib::Builtin::hexBinary;
8073             use SOAP::WSDL::XSD::Typelib::Builtin::ID;
8074             use SOAP::WSDL::XSD::Typelib::Builtin::IDREF;
8075             use SOAP::WSDL::XSD::Typelib::Builtin::IDREFS;
8076             use SOAP::WSDL::XSD::Typelib::Builtin::int;
8077             use SOAP::WSDL::XSD::Typelib::Builtin::integer;
8078             use SOAP::WSDL::XSD::Typelib::Builtin::language;
8079             use SOAP::WSDL::XSD::Typelib::Builtin::list;
8080             use SOAP::WSDL::XSD::Typelib::Builtin::long;
8081             use SOAP::WSDL::XSD::Typelib::Builtin::Name;
8082             use SOAP::WSDL::XSD::Typelib::Builtin::NCName;
8083             use SOAP::WSDL::XSD::Typelib::Builtin::negativeInteger;
8084             use SOAP::WSDL::XSD::Typelib::Builtin::NMTOKEN;
8085             use SOAP::WSDL::XSD::Typelib::Builtin::NMTOKENS;
8086             use SOAP::WSDL::XSD::Typelib::Builtin::nonNegativeInteger;
8087             use SOAP::WSDL::XSD::Typelib::Builtin::nonPositiveInteger;
8088             use SOAP::WSDL::XSD::Typelib::Builtin::normalizedString;
8089             use SOAP::WSDL::XSD::Typelib::Builtin::NOTATION;
8090             use SOAP::WSDL::XSD::Typelib::Builtin::positiveInteger;
8091             use SOAP::WSDL::XSD::Typelib::Builtin::QName;
8092             use SOAP::WSDL::XSD::Typelib::Builtin::short;
8093             use SOAP::WSDL::XSD::Typelib::Builtin::string;
8094             use SOAP::WSDL::XSD::Typelib::Builtin::time;
8095             use SOAP::WSDL::XSD::Typelib::Builtin::token;
8096             use SOAP::WSDL::XSD::Typelib::Builtin::unsignedByte;
8097             use SOAP::WSDL::XSD::Typelib::Builtin::unsignedInt;
8098             use SOAP::WSDL::XSD::Typelib::Builtin::unsignedLong;
8099             use SOAP::WSDL::XSD::Typelib::Builtin::unsignedShort;
8100            
8101             1;
8102            
8103             __END__
8104            
8105             SOAP_WSDL_XSD_TYPELIB_BUILTIN
8106              
8107 6         13 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/ENTITY.pm"} =
8108             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_ENTITY';
8109             package
8110             SOAP::WSDL::XSD::Typelib::Builtin::ENTITY;
8111             use strict;
8112             use warnings;
8113             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8114             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::NCName);
8115             Class::Std::initialize();
8116             1;
8117             SOAP_WSDL_XSD_TYPELIB_BUILTIN_ENTITY
8118              
8119 6         12 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/ID.pm"} =
8120             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_ID';
8121             package
8122             SOAP::WSDL::XSD::Typelib::Builtin::ID;
8123             use strict;
8124             use warnings;
8125             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8126             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::NCName);
8127            
8128             1;
8129             SOAP_WSDL_XSD_TYPELIB_BUILTIN_ID
8130              
8131 6         16 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/IDREF.pm"} =
8132             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_IDREF';
8133             package
8134             SOAP::WSDL::XSD::Typelib::Builtin::IDREF;
8135             use strict;
8136             use warnings;
8137             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8138             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::ID);
8139            
8140             1;
8141             SOAP_WSDL_XSD_TYPELIB_BUILTIN_IDREF
8142              
8143 6         70 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/IDREFS.pm"} =
8144             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_IDREFS';
8145             package
8146             SOAP::WSDL::XSD::Typelib::Builtin::IDREFS;
8147             use strict;
8148             use warnings;
8149             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8150             use base qw(
8151             SOAP::WSDL::XSD::Typelib::Builtin::list
8152             SOAP::WSDL::XSD::Typelib::Builtin::IDREF);
8153            
8154             1;
8155             SOAP_WSDL_XSD_TYPELIB_BUILTIN_IDREFS
8156              
8157 6         34 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/NCName.pm"} =
8158             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_NCNAME';
8159             package
8160             SOAP::WSDL::XSD::Typelib::Builtin::NCName;
8161             use strict;
8162             use warnings;
8163             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8164             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::Name);
8165             Class::Std::initialize();
8166             1;
8167             SOAP_WSDL_XSD_TYPELIB_BUILTIN_NCNAME
8168              
8169 6         38 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/NMTOKEN.pm"} =
8170             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_NMTOKEN';
8171             package
8172             SOAP::WSDL::XSD::Typelib::Builtin::NMTOKEN;
8173             use strict;
8174             use warnings;
8175             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8176             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::token);
8177             Class::Std::initialize();
8178             1;
8179             SOAP_WSDL_XSD_TYPELIB_BUILTIN_NMTOKEN
8180              
8181 6         21 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/NMTOKENS.pm"} =
8182             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_NMTOKENS';
8183             package
8184             SOAP::WSDL::XSD::Typelib::Builtin::NMTOKENS;
8185             use strict;
8186             use warnings;
8187             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8188            
8189             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::list
8190             SOAP::WSDL::XSD::Typelib::Builtin::NMTOKEN);
8191            
8192             Class::Std::initialize();
8193            
8194             1;
8195             SOAP_WSDL_XSD_TYPELIB_BUILTIN_NMTOKENS
8196              
8197 6         13 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/NOTATION.pm"} =
8198             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_NOTATION';
8199             package
8200             SOAP::WSDL::XSD::Typelib::Builtin::NOTATION;
8201             use strict;
8202             use warnings;
8203             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8204             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8205            
8206             1;
8207             SOAP_WSDL_XSD_TYPELIB_BUILTIN_NOTATION
8208              
8209 6         13 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/Name.pm"} =
8210             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_NAME';
8211             package
8212             SOAP::WSDL::XSD::Typelib::Builtin::Name;
8213             use strict;
8214             use warnings;
8215             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8216             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::token);
8217             Class::Std::initialize();
8218             1;
8219             SOAP_WSDL_XSD_TYPELIB_BUILTIN_NAME
8220              
8221 6         13 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/QName.pm"} =
8222             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_QNAME';
8223             package
8224             SOAP::WSDL::XSD::Typelib::Builtin::QName;
8225             use strict;
8226             use warnings;
8227             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8228             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8229            
8230             1;
8231            
8232             SOAP_WSDL_XSD_TYPELIB_BUILTIN_QNAME
8233              
8234 6         16 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/anySimpleType.pm"} =
8235             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_ANYSIMPLETYPE';
8236             package
8237             SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType;
8238             use strict;
8239             use warnings;
8240             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8241             use SOAP::WSDL::XSD::Typelib::Builtin::anyType;
8242             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anyType);
8243            
8244             my %value_of :ATTR(:get<value> :init_arg<value> :default<()>);
8245            
8246             # don't you never dare to play with this !
8247             our $___value = \%value_of;
8248            
8249             sub get_xmltype {
8250             my $class = ref $_[0];
8251             if ($class =~s{^SOAP::WSDL::XSD::Typelib::Builtin::}{}x) {
8252             return $class;
8253             }
8254             else {
8255             die "You must override get_xmltype in $class";
8256             }
8257             }
8258            
8259             ## use $_[n] for speed - we get called zillions of times...
8260             # and we don't need to return the last value...
8261             sub set_value { $value_of{ ${ $_[0] } } = $_[1] }
8262            
8263             # Default attribute handling
8264             # TODO add something for handling default attributes
8265             sub attr {
8266             }
8267            
8268             # use $_[n] for speed.
8269             # This is less readable, but notably faster.
8270             #
8271             # use postfix-if for speed. This is slightly faster, as it saves
8272             # perl from creating a pad (variable context).
8273             #
8274             # The methods below may get called zillions of times, so
8275             # every little statement matters...
8276            
8277             sub serialize {
8278             $_[1] ||= {};
8279             if (not defined $value_of{ ${$_[0]} }) {
8280             return $_[0]->start_tag({ %{ $_[1] }, nil => 1 }, undef);
8281             }
8282             return join q{}
8283             , $_[0]->start_tag($_[1], $value_of{ ${$_[0]} })
8284             , $value_of{ ${$_[0]} }
8285             , $_[0]->end_tag($_[1]);
8286             }
8287            
8288             sub as_string :STRINGIFY {
8289             return defined($value_of { ${ $_[0] } }) ? $value_of { ${ $_[0] } } : q{};
8290             }
8291            
8292             sub as_bool :BOOLIFY {
8293             return $value_of { ${ $_[0] } };
8294             }
8295            
8296             my $OBJECT_CACHE_REF = Class::Std::Fast::OBJECT_CACHE_REF();
8297            
8298             sub new {
8299             my $self = pop @{ $OBJECT_CACHE_REF->{ $_[0] } };
8300             $self = bless \(my $o = Class::Std::Fast::ID()), $_[0]
8301             if not defined $self;
8302             $value_of{ $$self } = $_[1]->{ value }
8303             if (($#_) && exists $_[1]->{ value });
8304             return $self;
8305             }
8306            
8307             Class::Std::initialize(); # make :BOOLIFY overloading serializable
8308            
8309             1;
8310             SOAP_WSDL_XSD_TYPELIB_BUILTIN_ANYSIMPLETYPE
8311              
8312 6         11 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/anyType.pm"} =
8313             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_ANYTYPE';
8314             package
8315             SOAP::WSDL::XSD::Typelib::Builtin::anyType;
8316             use strict;
8317             use warnings;
8318             use Class::Std::Fast::Storable constructor => 'none';
8319            
8320             use version; our $VERSION = qv('2.00.99_3');
8321            
8322             sub get_xmlns { 'http://www.w3.org/2001/XMLSchema' };
8323            
8324             sub get_xmltype { "xs:anyType" }
8325            
8326             # start_tag creates a XML start tag either for a XML element or a attribute.
8327             # The method is highly optimized for performance:
8328             # - operates on @_
8329             # - uses no private variables
8330             # - uses no blocks
8331            
8332             sub start_tag {
8333             # return empty string if no second argument ($opt) or no name
8334             return q{} if (! $#_);
8335             return q{} if (! exists $_[1]->{ name });
8336             # return attribute start if it's an attribute
8337             return qq{ $_[1]->{name}="} if $_[1]->{ attr };
8338             # return with xsi:nil="true" if it is nil
8339             return join
8340             q{} ,
8341             "<$_[1]->{ name }" ,
8342             # xsi:type
8343             (defined $_[1]->{ derived }) ? qq{ xsi:type="} . $_[0]->get_xmltype . q{"} : (),
8344             # xmlns=
8345             (defined $_[1]->{ xmlns }) ? qq{ xmlns="$_[1]->{ xmlns }"} : (),
8346             # attributes
8347             $_[0]->serialize_attr($_[1]) ,
8348             q{ xsi:nil="true"/>}
8349             if ($_[1]->{ nil });
8350             # return "empty" start tag if it's empty
8351             return join
8352             q{},
8353             "<$_[1]->{ name }",
8354             # xsi:type
8355             (defined $_[1]->{ derived }) ? qq{ xsi:type="} . $_[0]->get_xmltype . q{"} : (),
8356             # xmlns=
8357             (defined $_[1]->{ xmlns }) ? qq{ xmlns="$_[1]->{ xmlns }"} : (),
8358             $_[0]->serialize_attr($_[1]) ,
8359             '/>'
8360             if ($_[1]->{ empty });
8361             # return XML element start tag
8362             return join
8363             q{},
8364             "<$_[1]->{ name }",
8365             # xsi:type
8366             (defined $_[1]->{ derived }) ? qq{ xsi:type="} . $_[0]->get_xmltype . q{"} : (),
8367             # xmlns=
8368             (defined $_[1]->{ xmlns }) ? qq{ xmlns="$_[1]->{ xmlns }"} : (),
8369             , $_[0]->serialize_attr($_[1])
8370             , '>';
8371             }
8372            
8373             # start_tag creates a XML end tag either for a XML element or a attribute.
8374             # The method is highly optimized for performance:
8375             # - operates on @_
8376             # - uses no private variables
8377             # - uses no blocks
8378             sub end_tag {
8379             # return empty string if no second argument ($opt) or no name
8380             return q{} if (! $#_);
8381             return q{} if (! exists $_[1]->{ name });
8382             return q{"} if $_[1]->{ attr };
8383             return "</$_[1]->{name}>";
8384             };
8385            
8386             sub serialize_attr {};
8387            
8388             sub serialize_qualified :STRINGIFY {
8389             return $_[0]->serialize( { qualified => 1 } );
8390             }
8391            
8392             sub as_list :ARRAYIFY {
8393             return [ $_[0] ];
8394             }
8395            
8396             Class::Std::initialize(); # make :STRINGIFY overloading work
8397            
8398             1;
8399            
8400             SOAP_WSDL_XSD_TYPELIB_BUILTIN_ANYTYPE
8401              
8402 6         14 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/anyURI.pm"} =
8403             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_ANYURI';
8404             package
8405             SOAP::WSDL::XSD::Typelib::Builtin::anyURI;
8406             use strict;
8407             use warnings;
8408            
8409             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8410             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8411            
8412             1;
8413             SOAP_WSDL_XSD_TYPELIB_BUILTIN_ANYURI
8414              
8415 6         12 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/base64Binary.pm"} =
8416             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_BASE64BINARY';
8417             package
8418             SOAP::WSDL::XSD::Typelib::Builtin::base64Binary;
8419             use strict;
8420             use warnings;
8421            
8422             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8423             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8424            
8425             1;
8426            
8427             SOAP_WSDL_XSD_TYPELIB_BUILTIN_BASE64BINARY
8428              
8429 6         14 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/boolean.pm"} =
8430             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_BOOLEAN';
8431             package
8432             SOAP::WSDL::XSD::Typelib::Builtin::boolean;
8433             use strict;
8434             use warnings;
8435             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8436            
8437             use version; our $VERSION = qv('2.00.99_3');
8438            
8439             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8440            
8441             sub serialize {
8442             $_[1] ||= {};
8443             my $value =$_[0]->get_value();
8444             return $_[0]->start_tag({ %{$_[1]}, nil => 1})
8445             if not defined $value;
8446             return join q{}
8447             , $_[0]->start_tag($_[1])
8448             , $value && $value ne 'false' ? 'true' : 'false'
8449             , $_[0]->end_tag($_[1]);
8450             }
8451            
8452             sub as_string :STRINGIFY {
8453             my $value = $_[0]->get_value();
8454             return q{} if not defined $value;
8455             return ($value && $value ne 'false') ? 1 : 0;
8456             }
8457            
8458             sub as_num :NUMERIFY :BOOLIFY {
8459             my $value = $_[0]->get_value();
8460             return ($value && $value ne 'false') ? 1 : 0;
8461             }
8462            
8463             sub set_value {
8464             $_[0]->SUPER::set_value( defined $_[1]
8465             ? ($_[1] ne 'false' && ($_[1]) )
8466             ? 1 : 0
8467             : 0);
8468             }
8469            
8470             sub delete_value { $_[0]->SUPER::set_value(undef) }
8471            
8472             Class::Std::Fast::initialize(); # make :BOOLIFY overloading serializable
8473            
8474             1;
8475             SOAP_WSDL_XSD_TYPELIB_BUILTIN_BOOLEAN
8476              
8477 6         23 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/byte.pm"} =
8478             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_BYTE';
8479             package
8480             SOAP::WSDL::XSD::Typelib::Builtin::byte;
8481             use strict;
8482             use warnings;
8483             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8484             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::short);
8485             Class::Std::initialize();
8486             1;
8487             SOAP_WSDL_XSD_TYPELIB_BUILTIN_BYTE
8488              
8489 6         11 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/date.pm"} =
8490             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_DATE';
8491             package
8492             SOAP::WSDL::XSD::Typelib::Builtin::date;
8493             use strict;
8494             use warnings;
8495             use Date::Parse;
8496             use Date::Format;
8497            
8498             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8499             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8500            
8501             sub set_value {
8502             # use set_value from base class if we have a XML-DateTime format
8503             #2037-12-31+01:00
8504             if (
8505             $_[1] =~ m{ ^\d{4} \- \d{2} \- \d{2}
8506             (:? [\+\-] \d{2} \: \d{2} )$
8507             }xms
8508             ) {
8509             $_[0]->SUPER::set_value($_[1])
8510             }
8511             # converting a date is hard work: It needs a timezone, because
8512             # 2007-12-30+12:00 and 2007-12-31-12:00 mean the same day - just in
8513             # different locations.
8514             # strftime actually prints out the correct date, but always prints the
8515             # local timezone with %z.
8516             # So, if our timezone is not 0, we strftime it without timezone and
8517             # append it by hand by the following formula:
8518             # The timezone hours are the int (timesone seconds / 3600)
8519             # The timezone minutes (if someone ever specifies something like that)
8520             # are int( (seconds % 3600) / 60 )
8521             # say, int( (seconds modulo 3600) / 60 )
8522             #
8523             # If we have no timezone (meaning the timezone is
8524             else {
8525             # strptime sets empty values to undef - and strftime doesn't like that...
8526             my @time_from = strptime($_[1]);
8527             my $time_zone_seconds = $time_from[6];
8528             @time_from = map { (! defined $_) ? 0 : $_ } @time_from;
8529             # use Data::Dumper;
8530             # warn Dumper \@time_from, sprintf('%+03d%02d', $time_from[6] / 3600, $time_from[6] % 60 );
8531             my $time_str;
8532             if (defined $time_zone_seconds) {
8533             $time_str = sprintf('%04d-%02d-%02d%+03d:%02d', $time_from[5]+1900, $time_from[4]+1, $time_from[3], int($time_from[6] / 3600), int($time_from[6] % 3600) / 60);
8534             }
8535             else {
8536             $time_str = strftime( '%Y-%m-%d%z', @time_from );
8537             substr $time_str, -2, 0, ':';
8538             }
8539            
8540             # ? strftime( '%Y-%m-%d', @time_from )
8541             # . sprintf('%+03d%02d', int($time_from[6] / 3600), int ( ($time_from[6] % 3600) / 60 ) )
8542             # : do {
8543             # strftime( '%Y-%m-%d%z', @time_from );
8544             # };
8545             # substr $time_str, -2, 0, ':';
8546             $_[0]->SUPER::set_value($time_str);
8547             }
8548             }
8549            
8550             1;
8551            
8552             SOAP_WSDL_XSD_TYPELIB_BUILTIN_DATE
8553              
8554 6         12 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/dateTime.pm"} =
8555             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_DATETIME';
8556             package
8557             SOAP::WSDL::XSD::Typelib::Builtin::dateTime;
8558            
8559             use strict;
8560             use warnings;
8561            
8562             use Date::Parse;
8563             use Date::Format;
8564            
8565            
8566             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8567             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8568            
8569             sub set_value {
8570            
8571             # use set_value from base class if we have a XML-DateTime format
8572             #2037-12-31T00:00:00.0000000+01:00
8573             return $_[0]->SUPER::set_value( $_[1] ) if not defined $_[1];
8574             return $_[0]->SUPER::set_value( $_[1] )
8575             if (
8576             $_[1] =~ m{ ^\d{4} \- \d{2} \- \d{2}
8577             T \d{2} \: \d{2} \: \d{2} (:? \. \d{1,7} )?
8578             [\+\-] \d{2} \: \d{2} $
8579             }xms
8580             );
8581            
8582             # strptime sets empty values to undef - and strftime doesn't like that...
8583             my @time_from = strptime( $_[1] );
8584            
8585             die "Illegal date" if not defined $time_from[5];
8586            
8587             # strftime doesn't like undefs
8588             @time_from = map { !defined $_ ? 0 : $_ } @time_from;
8589            
8590             my $time_str;
8591             if ( $time_from[-1] ) {
8592             $time_str = sprintf(
8593             '%04d-%02d-%02dT%02d:%02d:%02d.0000000%+03d:%02d',
8594             $time_from[5] + 1900,
8595             $time_from[4] + 1,
8596             $time_from[3],
8597             $time_from[2],
8598             $time_from[1],
8599             $time_from[0],
8600             int( $time_from[6] / 3600 ),
8601             int( $time_from[6] % 3600 ) / 60
8602             );
8603             }
8604             else {
8605             $time_str = strftime( '%Y-%m-%dT%H:%M:%S%z', @time_from );
8606             substr $time_str, -2, 0, ':';
8607             }
8608            
8609             $_[0]->SUPER::set_value($time_str);
8610             }
8611            
8612             1;
8613             SOAP_WSDL_XSD_TYPELIB_BUILTIN_DATETIME
8614              
8615 6         13 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/decimal.pm"} =
8616             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_DECIMAL';
8617             package
8618             SOAP::WSDL::XSD::Typelib::Builtin::decimal;
8619             use strict;
8620             use warnings;
8621             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8622             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8623            
8624             sub as_num :NUMERIFY :BOOLIFY {
8625             return $_[0]->get_value();
8626             }
8627            
8628             Class::Std::Fast::initialize(); # make :NUMERIFY :BOOLIFY overloading serializable
8629            
8630             1;
8631             SOAP_WSDL_XSD_TYPELIB_BUILTIN_DECIMAL
8632              
8633 6         12 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/double.pm"} =
8634             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_DOUBLE';
8635             package
8636             SOAP::WSDL::XSD::Typelib::Builtin::double;
8637             use strict;
8638             use warnings;
8639             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8640             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8641            
8642             sub as_num :NUMERIFY {
8643             return $_[0]->get_value();
8644             }
8645            
8646             Class::Std::initialize(); # make :NUMERIFY overloading serializable
8647            
8648             1;
8649             SOAP_WSDL_XSD_TYPELIB_BUILTIN_DOUBLE
8650              
8651 6         10 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/duration.pm"} =
8652             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_DURATION';
8653             package
8654             SOAP::WSDL::XSD::Typelib::Builtin::duration;
8655             use strict;
8656             use warnings;
8657             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8658             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8659            
8660             1;
8661             SOAP_WSDL_XSD_TYPELIB_BUILTIN_DURATION
8662              
8663 6         13 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/float.pm"} =
8664             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_FLOAT';
8665             package
8666             SOAP::WSDL::XSD::Typelib::Builtin::float;
8667             use strict;
8668             use warnings;
8669             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8670             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8671            
8672             sub as_num :NUMERIFY {
8673             return $_[0]->get_value();
8674             }
8675            
8676             Class::Std::initialize(); # make :NUMERIFY overloading serializable
8677            
8678             1;
8679            
8680             SOAP_WSDL_XSD_TYPELIB_BUILTIN_FLOAT
8681              
8682 6         11 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/gDay.pm"} =
8683             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_GDAY';
8684             package
8685             SOAP::WSDL::XSD::Typelib::Builtin::gDay;
8686             use strict;
8687             use warnings;
8688             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8689             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8690            
8691             1;
8692             SOAP_WSDL_XSD_TYPELIB_BUILTIN_GDAY
8693              
8694 6         12 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/gMonth.pm"} =
8695             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_GMONTH';
8696             package
8697             SOAP::WSDL::XSD::Typelib::Builtin::gMonth;
8698             use strict;
8699             use warnings;
8700            
8701             # Speed up. Class::Std::new is slow - and we don't need it's functionality...
8702             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8703             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8704            
8705             1;
8706             SOAP_WSDL_XSD_TYPELIB_BUILTIN_GMONTH
8707              
8708 6         10 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/gMonthDay.pm"} =
8709             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_GMONTHDAY';
8710             package
8711             SOAP::WSDL::XSD::Typelib::Builtin::gMonthDay;
8712             use strict;
8713             use warnings;
8714             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8715             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8716            
8717             1;
8718             SOAP_WSDL_XSD_TYPELIB_BUILTIN_GMONTHDAY
8719              
8720 6         14 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/gYear.pm"} =
8721             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_GYEAR';
8722             package
8723             SOAP::WSDL::XSD::Typelib::Builtin::gYear;
8724             use strict;
8725             use warnings;
8726             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8727             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8728            
8729             1;
8730             SOAP_WSDL_XSD_TYPELIB_BUILTIN_GYEAR
8731              
8732 6         11 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/gYearMonth.pm"} =
8733             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_GYEARMONTH';
8734             package
8735             SOAP::WSDL::XSD::Typelib::Builtin::gYearMonth;
8736             use strict;
8737             use warnings;
8738             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8739             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8740            
8741             1;
8742             SOAP_WSDL_XSD_TYPELIB_BUILTIN_GYEARMONTH
8743              
8744 6         15 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/hexBinary.pm"} =
8745             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_HEXBINARY';
8746             package
8747             SOAP::WSDL::XSD::Typelib::Builtin::hexBinary;
8748             use strict;
8749             use warnings;
8750             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8751             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8752            
8753             1;
8754             SOAP_WSDL_XSD_TYPELIB_BUILTIN_HEXBINARY
8755              
8756 6         11 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/int.pm"} =
8757             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_INT';
8758             package
8759             SOAP::WSDL::XSD::Typelib::Builtin::int;
8760             use strict;
8761             use warnings;
8762             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8763             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::long);
8764            
8765             1;
8766             SOAP_WSDL_XSD_TYPELIB_BUILTIN_INT
8767              
8768 6         12 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/integer.pm"} =
8769             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_INTEGER';
8770             package
8771             SOAP::WSDL::XSD::Typelib::Builtin::integer;
8772             use strict;
8773             use warnings;
8774             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8775             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::decimal);
8776            
8777             1;
8778             SOAP_WSDL_XSD_TYPELIB_BUILTIN_INTEGER
8779              
8780 6         10 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/language.pm"} =
8781             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_LANGUAGE';
8782             package
8783             SOAP::WSDL::XSD::Typelib::Builtin::language;
8784             use strict;
8785             use warnings;
8786             use Class::Std::Fast::Storable;
8787             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::token);
8788            
8789             1;
8790             SOAP_WSDL_XSD_TYPELIB_BUILTIN_LANGUAGE
8791              
8792 6         14 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/list.pm"} =
8793             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_LIST';
8794             package
8795             SOAP::WSDL::XSD::Typelib::Builtin::list;
8796             use strict;
8797             use warnings;
8798            
8799             sub serialize {
8800             my ($self, $opt) = @_;
8801             $opt = {} if not $opt;
8802             my $value = $self->get_value();
8803             return $self->start_tag({ %$opt, nil => 1 }) if not defined $value;
8804             $value = [ $value ] if not ref $value;
8805             return join q{}, $self->start_tag($opt, $value)
8806             , join( q{ }, @{ $value } )
8807             , $self->end_tag($opt, $value);
8808             }
8809             1;
8810            
8811             __END__
8812            
8813             =pod
8814            
8815             =head1 NAME
8816            
8817             SOAP::WSDL::XSD::Typelib::Builtin::list - list derivation base class
8818            
8819             =head1 DESCRIPTION
8820            
8821             To derive from some class by list, just inherit from list.
8822            
8823             Make sure SOAP::WSDL::XSD::Typelib::Builtin::list is before the type
8824             to derive from in the @ISA list.
8825            
8826             =head1 LICENSE AND COPYRIGHT
8827            
8828             Copyright (c) 2007 Martin Kutter. All rights reserved.
8829            
8830             This file is part of SOAP-WSDL. You may distribute/modify it under
8831             the same terms as perl itself
8832            
8833             =head1 AUTHOR
8834            
8835             Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
8836            
8837             =cut
8838             SOAP_WSDL_XSD_TYPELIB_BUILTIN_LIST
8839              
8840 6         14 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/long.pm"} =
8841             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_LONG';
8842             package
8843             SOAP::WSDL::XSD::Typelib::Builtin::long;
8844             use strict;
8845             use warnings;
8846             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8847             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::integer);
8848            
8849             1;
8850             SOAP_WSDL_XSD_TYPELIB_BUILTIN_LONG
8851              
8852 6         12 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/negativeInteger.pm"} =
8853             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_NEGATIVEINTEGER';
8854             package
8855             SOAP::WSDL::XSD::Typelib::Builtin::negativeInteger;
8856             use strict;
8857             use warnings;
8858             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8859             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::nonPositiveInteger);
8860            
8861             1;
8862             SOAP_WSDL_XSD_TYPELIB_BUILTIN_NEGATIVEINTEGER
8863              
8864 6         14 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/nonNegativeInteger.pm"} =
8865             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_NONNEGATIVEINTEGER';
8866             package
8867             SOAP::WSDL::XSD::Typelib::Builtin::nonNegativeInteger;
8868             use strict;
8869             use warnings;
8870             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8871             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::integer);
8872            
8873             1;
8874             SOAP_WSDL_XSD_TYPELIB_BUILTIN_NONNEGATIVEINTEGER
8875              
8876 6         17 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/nonPositiveInteger.pm"} =
8877             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_NONPOSITIVEINTEGER';
8878             package
8879             SOAP::WSDL::XSD::Typelib::Builtin::nonPositiveInteger;
8880             use strict;
8881             use warnings;
8882             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8883             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::integer);
8884            
8885             1;
8886             SOAP_WSDL_XSD_TYPELIB_BUILTIN_NONPOSITIVEINTEGER
8887              
8888 6         20 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/normalizedString.pm"} =
8889             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_NORMALIZEDSTRING';
8890             package
8891             SOAP::WSDL::XSD::Typelib::Builtin::normalizedString;
8892             use strict;
8893             use warnings;
8894             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8895             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::string);
8896            
8897             # replace all \t, \r, \n by \s
8898             sub set_value {
8899             my $value = $_[1];
8900             $value =~ s{ [\r\n\t]+ }{ }xmsg if defined($value);
8901             $_[0]->SUPER::set_value($value);
8902             }
8903             Class::Std::initialize();
8904             1;
8905             SOAP_WSDL_XSD_TYPELIB_BUILTIN_NORMALIZEDSTRING
8906              
8907 6         9 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/positiveInteger.pm"} =
8908             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_POSITIVEINTEGER';
8909             package
8910             SOAP::WSDL::XSD::Typelib::Builtin::positiveInteger;
8911             use strict;
8912             use warnings;
8913             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8914             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::nonNegativeInteger);
8915            
8916             1;
8917             SOAP_WSDL_XSD_TYPELIB_BUILTIN_POSITIVEINTEGER
8918              
8919 6         16 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/short.pm"} =
8920             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_SHORT';
8921             package
8922             SOAP::WSDL::XSD::Typelib::Builtin::short;
8923             use strict;
8924             use warnings;
8925             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8926             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::int);
8927            
8928             1;
8929             SOAP_WSDL_XSD_TYPELIB_BUILTIN_SHORT
8930              
8931 6         27 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/string.pm"} =
8932             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_STRING';
8933             package
8934             SOAP::WSDL::XSD::Typelib::Builtin::string;
8935             use strict;
8936             use warnings;
8937             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8938             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8939            
8940             my %char2entity = (
8941             q{&} => q{&amp;},
8942             q{<} => q{&lt;},
8943             q{>} => q{&gt;},
8944             q{"} => q{&quot;},
8945             q{'} => q{&apos;},
8946             );
8947            
8948             # sub get_xmltype { "xs:string" }
8949            
8950             sub serialize {
8951             $_[1] ||= {};
8952            
8953             my $value = $_[0]->get_value();
8954            
8955             return $_[0]->start_tag({ %{ $_[1] }, nil => 1})
8956             if not defined $value;
8957            
8958             # HTML::Entities does the same - and more, thus it's around 1/3 slower...
8959             $value =~ s{([&<>"'])}{$char2entity{$1}}xgmso;
8960            
8961             return join q{}, $_[0]->start_tag($_[1], $value)
8962             #, encode_entities( $value, q{&<>"'} )
8963             , $value
8964             , $_[0]->end_tag($_[1]);
8965             }
8966            
8967             sub as_bool :BOOLIFY {
8968             return $_[0]->get_value();
8969             }
8970            
8971             Class::Std::initialize();
8972             1;
8973             SOAP_WSDL_XSD_TYPELIB_BUILTIN_STRING
8974              
8975 6         14 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/time.pm"} =
8976             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_TIME';
8977             package
8978             SOAP::WSDL::XSD::Typelib::Builtin::time;
8979             use strict;
8980             use warnings;
8981             use Date::Parse;
8982             use Date::Format;
8983             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
8984             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
8985            
8986             use version; our $VERSION = qv('2.00.99_3');
8987            
8988             sub set_value {
8989             # use set_value from base class if we have a XML-Time format
8990             # 00:00:00.0000000+01:00
8991             if (
8992             $_[1] =~ m{ ^ \d{2} \: \d{2} \: \d{2} (:? \. \d{1,7} )?
8993             [\+\-] \d{2} \: \d{2} $
8994             }xms
8995             ) {
8996             $_[0]->SUPER::set_value($_[1])
8997             }
8998             # use a combination of strptime and strftime for converting the date
8999             # Unfortunately, strftime outputs the time zone as [+-]0000, whereas XML
9000             # whants it as [+-]00:00
9001             # We leave out the optional nanoseconds part, as it would always be empty.
9002             else {
9003             # strptime sets empty values to undef - and strftime doesn't like that...
9004             # we even need to set it to 1 to prevent a "Day '0' out of range 1..31" warning..
9005            
9006             # we need to set the current date for correct TZ conversion -
9007             # could be daylight savings time
9008             my @now = localtime;
9009             my @time_from = map { my $alternative = shift @now;
9010             ! defined $_
9011             ? $alternative
9012             : $_ } strptime($_[1]);
9013             undef $time_from[-1];
9014             my $time_str = strftime( '%H:%M:%S%z', @time_from );
9015             substr $time_str, -2, 0, ':';
9016             $_[0]->SUPER::set_value($time_str);
9017             }
9018             }
9019            
9020             1;
9021             SOAP_WSDL_XSD_TYPELIB_BUILTIN_TIME
9022              
9023 6         37 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/token.pm"} =
9024             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_TOKEN';
9025             package
9026             SOAP::WSDL::XSD::Typelib::Builtin::token;
9027             use strict;
9028             use warnings;
9029             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
9030             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::normalizedString);
9031             Class::Std::initialize();
9032             1;
9033             SOAP_WSDL_XSD_TYPELIB_BUILTIN_TOKEN
9034              
9035 6         13 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/unsignedByte.pm"} =
9036             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_UNSIGNEDBYTE';
9037             package
9038             SOAP::WSDL::XSD::Typelib::Builtin::unsignedByte;
9039             use strict;
9040             use warnings;
9041             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
9042             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::unsignedShort);
9043            
9044             1;
9045             SOAP_WSDL_XSD_TYPELIB_BUILTIN_UNSIGNEDBYTE
9046              
9047 6         13 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/unsignedInt.pm"} =
9048             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_UNSIGNEDINT';
9049             package
9050             SOAP::WSDL::XSD::Typelib::Builtin::unsignedInt;
9051             use strict;
9052             use warnings;
9053             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
9054             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::unsignedLong);
9055            
9056             1;
9057             SOAP_WSDL_XSD_TYPELIB_BUILTIN_UNSIGNEDINT
9058              
9059 6         12 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/unsignedLong.pm"} =
9060             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_UNSIGNEDLONG';
9061             package
9062             SOAP::WSDL::XSD::Typelib::Builtin::unsignedLong;
9063             use strict;
9064             use warnings;
9065             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
9066             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::nonNegativeInteger);
9067            
9068             1;
9069             SOAP_WSDL_XSD_TYPELIB_BUILTIN_UNSIGNEDLONG
9070              
9071 6         15 $fatpacked{"SOAP/WSDL/XSD/Typelib/Builtin/unsignedShort.pm"} =
9072             <<'SOAP_WSDL_XSD_TYPELIB_BUILTIN_UNSIGNEDSHORT';
9073             package
9074             SOAP::WSDL::XSD::Typelib::Builtin::unsignedShort;
9075             use strict;
9076             use warnings;
9077             use Class::Std::Fast::Storable constructor => 'none', cache => 1;
9078             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::unsignedInt);
9079            
9080             1;
9081             SOAP_WSDL_XSD_TYPELIB_BUILTIN_UNSIGNEDSHORT
9082              
9083 6         16 $fatpacked{"SOAP/WSDL/XSD/Typelib/ComplexType.pm"} =
9084             <<'SOAP_WSDL_XSD_TYPELIB_COMPLEXTYPE';
9085             #!/usr/bin/perl
9086             package
9087             SOAP::WSDL::XSD::Typelib::ComplexType;
9088             use strict;
9089             use warnings;
9090             use Carp;
9091             use SOAP::WSDL::XSD::Typelib::Builtin;
9092             use Scalar::Util qw(blessed);
9093             use Data::Dumper;
9094             require Class::Std::Fast::Storable;
9095            
9096             use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anyType);
9097            
9098             use version; our $VERSION = qv('2.00.99_3');
9099            
9100             # remove in 2.1
9101             our $AS_HASH_REF_WITHOUT_ATTRIBUTES = 0;
9102            
9103             my %ELEMENT_FORM_QUALIFIED_OF; # denotes whether elements are qualified
9104             my %ELEMENTS_FROM; # order of elements in a class
9105             my %ATTRIBUTES_OF; # references to value hashes
9106             my %CLASSES_OF; # class names of elements in a class
9107             my %NAMES_OF; # XML names of elements in a class
9108            
9109            
9110             # XML Attribute handling
9111             my %xml_attr_of :ATTR();
9112            
9113             # Namespace handling
9114             my %xmlns_of :ATTR();
9115            
9116             our $MAY_HAVE_CHILDREN = 1;
9117            
9118             # don't you ever dare to use this !
9119             our $___classes_of_ref = \%CLASSES_OF;
9120             our $___attributes_of_ref = \%ATTRIBUTES_OF;
9121             our $___xml_attribute_of_ref = \%xml_attr_of;
9122            
9123             # STORABLE_ methods for supporting Class::Std::Fast::Storable.
9124             # We could also handle them via AUTOMETHOD,
9125             # but AUTOMETHOD should always croak...
9126             # Actually, AUTOMETHOD is faster (~1%) if Class::Std::Fast is loaded
9127             # properly, and slower (~10%) if not.
9128             # Hmmm. Trade 1% for 10?
9129            
9130             my %STORABLE_METHODS = (
9131             STORABLE_freeze_pre => undef,
9132             STORABLE_freeze_post => undef,
9133             STORABLE_thaw_pre => undef,
9134             STORABLE_thaw_post => undef,
9135             );
9136            
9137             # for error reporting. Eases working with data objects...
9138             sub AUTOMETHOD {
9139             # return before unpacking @_ for speed reasons
9140             return if exists $STORABLE_METHODS{$_};
9141            
9142             my ($self, $ident, @args_from) = @_;
9143             my $class = ref $self || $self or die "Cannot call AUTOMETHOD as function";
9144            
9145             # Test whether we're called from ->can()
9146             my @caller = caller(1);
9147            
9148             # return if not called by AUTOLOAD - caller must be something like can()
9149             # Unfortunately we cannot test for "UNIVERSAL::can", as it gets overwritten
9150             # by both Class::Std and Class::Std::Fast, and we don't know the loading
9151             # order (Class::Std::Fast should be loaded before for maximum speedup)
9152             return if $caller[3] ne 'Class::Std::AUTOLOAD';
9153            
9154             confess "Can't locate object method \"$_\" via package \"$class\". \n"
9155             . "Valid methods are: "
9156             . join(', ', map { ("get_$_" , "set_$_") } keys %{ $ATTRIBUTES_OF{ $class } })
9157             . "\n"
9158             }
9159            
9160             sub attr {
9161             # We're working on @_ for speed.
9162             # Normally, the first line would look like this:
9163             # my $self = shift;
9164            
9165             my $class = $_[0]->__get_attr_class()
9166             or return;
9167            
9168             # pass arguments to attributes constructor (if any);
9169             # lets attr($foo) work as setter
9170             if ($_[1]) {
9171             return $xml_attr_of{ ${$_[0]} } = $class->new($_[1]);
9172             }
9173             return $xml_attr_of{ ${$_[0]} } if exists $xml_attr_of{ ${$_[0]} };
9174             return $xml_attr_of{ ${$_[0]} } = $class->new();
9175             }
9176            
9177             sub serialize_attr {
9178             return q{} if not $xml_attr_of{ ${ $_[0] } };
9179             return $xml_attr_of{ ${ $_[0] } }->serialize();
9180             }
9181            
9182             # TODO: are complextypes are always true ?
9183             sub as_bool :BOOLIFY { 1 }
9184            
9185             sub as_hash_ref {
9186             # we're working on $_[0] for speed (as always...)
9187             #
9188             # Normally the first line would read:
9189             # my ($self, $ignore_attributes) = @_;
9190             #
9191             my $attributes_ref = $ATTRIBUTES_OF{ ref $_[0] };
9192            
9193             my $hash_of_ref = {};
9194             if ($_[0]->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType')) {
9195             $hash_of_ref->{ value } = $_[0]->get_value();
9196             }
9197             else {
9198             foreach my $attribute (keys %{ $attributes_ref }) {
9199             next if not defined $attributes_ref->{ $attribute }->{ ${ $_[0] } };
9200             my $value = $attributes_ref->{ $attribute }->{ ${ $_[0] } };
9201            
9202             $hash_of_ref->{ $attribute } = blessed $value
9203             ? $value->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType')
9204             ? $value->get_value()
9205             : $value->as_hash_ref($_[1])
9206             : ref $value eq 'ARRAY'
9207             ? [
9208             map {
9209             $_->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType')
9210             ? $_->get_value()
9211             : $_->as_hash_ref($_[1])
9212             } @{ $value }
9213             ]
9214             : die "Neither blessed obj nor list ref";
9215             };
9216             }
9217            
9218             # $AS_HASH_REF_WITHOUT_ATTRIBUTES is deprecated by NOW and will be removed
9219             # in 2.1
9220             return $hash_of_ref if $_[1] or $AS_HASH_REF_WITHOUT_ATTRIBUTES;
9221            
9222            
9223             if (exists $xml_attr_of{ ${ $_[0] } }) {
9224             $hash_of_ref->{ xmlattr } = $xml_attr_of{ ${ $_[0] } }->as_hash_ref();
9225             }
9226            
9227             return $hash_of_ref;
9228             }
9229            
9230             # we store per-class elements.
9231             # call as __PACKAGE__->_factory
9232             sub _factory {
9233             my $class = shift;
9234             $ELEMENTS_FROM{ $class } = shift;
9235             $ATTRIBUTES_OF{ $class } = shift;
9236             $CLASSES_OF{ $class } = shift;
9237             $NAMES_OF{ $class } = shift;
9238            
9239             no strict qw(refs);
9240             no warnings qw(redefine);
9241            
9242             while (my ($name, $attribute_ref) = each %{ $ATTRIBUTES_OF{ $class } } ) {
9243             my $type = $CLASSES_OF{ $class }->{ $name }
9244             or croak "No class given for $name";
9245            
9246             Class::Load::is_class_loaded($type)
9247             or eval { Class::Load::load_class $type }
9248             or croak $@;
9249            
9250             # check now, so we don't need to do it later.
9251             # $is_list is used in the methods created. Filling it now means
9252             # we don't have to check it every time the method is called, but
9253             # can just use $is_list, which will hold the value assigned to
9254             # it when the method was created.
9255             my $is_list = $type->isa('SOAP::WSDL::XSD::Typelib::Builtin::list');
9256            
9257             # The set_$name method below looks rather weird,
9258             # but is optimized for performance.
9259             #
9260             # We could use sub calls for sure, but these are much slower. And
9261             # the logic is not that easy:
9262             #
9263             # we accept:
9264             # a) objects
9265             # b) scalars
9266             # c) list refs
9267             # d) hash refs
9268             # e) mixed stuff of all of the above, so we have to set our child to
9269             # a) value if it's an object
9270             # b) New object of expected class with value for simple values
9271             # c 1) New object with value for list values and list type
9272             # c 2) List ref of new objects with value for list values and
9273             # non-list type
9274             # c + e 1) List ref of objects for list values (list of objects)
9275             # and non-list type
9276             # c + e 2) List ref of new objects for list values (list of hashes)
9277             # and non-list type where the hash ref is passed to new as
9278             # argument
9279             # d) New object with values passed to new for HASH references
9280             #
9281             # We throw an error on
9282             # a) list refs of list refs - don't know what to do with this (maybe
9283             # use for lists of list types ?)
9284             # b) wrong object types
9285             # c) non-blessed non-ARRAY/HASH references - if you can define semantics
9286             # for GLOB or SCALAR references, feel free to add them.
9287             # d) we should also die for non-blessed non-ARRAY/HASH references in
9288             # lists but don't do yet - oh my !
9289            
9290             # keep in sync with Generator::Template::Plugin::XSD - maybe use
9291             # function to allow substituting via symbol table...
9292             my $method_name = $name;
9293             $method_name =~s{[\.\-]}{_}xmsg;
9294             *{ "$class\::set_$method_name" } = sub {
9295             if (not $#_) {
9296             delete $attribute_ref->{ ${ $_[0] } };
9297             return;
9298             };
9299             my $is_ref = ref $_[1];
9300             $attribute_ref->{ ${ $_[0] } } = ($is_ref)
9301             ? ($is_ref eq 'ARRAY')
9302             ? $is_list # remembered from outside closure
9303             ? $type->new({ value => $_[1] }) # it's a list element - can take list ref as value
9304             : [ map { # it's not a list element - set value to list of objects
9305             ref $_
9306             ? ref $_ eq 'HASH'
9307             ? $type->new($_)
9308             : ref $_ eq $type
9309             ? $_
9310             : croak "cannot use " . ref($_) . " reference as value for $name - $type required"
9311             : $type->new({ value => $_ })
9312             } @{ $_[1] }
9313             ]
9314             : $is_ref eq 'HASH'
9315             ? $type->new( $_[1] )
9316             # neither ARRAY nor HASH - probably an object... -
9317             # do we need to test for it being blessed?
9318             : blessed $_[1] && $_[1]->isa($type) # of required type ?
9319             ? $_[1] # use it
9320             : die croak "cannot use $is_ref reference as value for $name - $type required"
9321            
9322             # not $is_ref
9323             : defined $_[1] ? $type->new({ value => $_[1] }) : () ;
9324             return;
9325             };
9326            
9327             *{ "$class\::add_$method_name" } = sub {
9328             warn "attempting to add empty value to " . ref $_[0]
9329             if not defined $_[1];
9330            
9331             # first call
9332             # test for existance, not for definedness
9333             if (not exists $attribute_ref->{ ${ $_[0]} }) {
9334             $attribute_ref->{ ${ $_[0]} } = $_[1];
9335             return;
9336             }
9337            
9338             if (not ref $attribute_ref->{ ${ $_[0]} } eq 'ARRAY') {
9339             # second call: listify previous value if it's no list and add current
9340             $attribute_ref->{ ${ $_[0]} } = [ $attribute_ref->{ ${ $_[0]} }, $_[1] ];
9341             return;
9342             }
9343            
9344             # second and following: add to list
9345             push @{ $attribute_ref->{ ${ $_[0]} } }, $_[1];
9346             return;
9347             };
9348             }
9349            
9350             # TODO Could be moved as normal method into base class, e.g. here.
9351             # Hmm. let's see...
9352             *{ "$class\::new" } = sub {
9353             # We're working on @_ for speed.
9354             # Normally, the first line would look like this:
9355             # my ($class, $args_of) = @_;
9356             #
9357             # The hanging side comment show you what would be there, then.
9358            
9359             # Read as:
9360             # my $self = bless \(my $o = Class::Std::Fast::ID()), $class;
9361             my $self = bless \(my $o = Class::Std::Fast::ID()), $_[0];
9362            
9363             # Set attributes if passed via { xmlattr => \%attributes }
9364             #
9365             # This works just because
9366             # a) xmlattr cannot be used as valid XML identifier (it starts
9367             # with "xml" which is banned by the XML schema standard)
9368             # b) $o->attr($attribute_ref) passes $attribute_ref to the
9369             # attribute object's constructor
9370             # c) we are in the object's constructor here (which means that)
9371             # no attributes object can have been legally constructed
9372             # before.
9373             if (exists $_[1]->{xmlattr}) { # $args_of->{xmlattr}
9374             $self->attr(delete $_[1]->{xmlattr});
9375             }
9376            
9377             # iterate over keys of arguments
9378             # and call set appropriate field in clase
9379             map { ($ATTRIBUTES_OF{ $class }->{ $_ })
9380             ? do {
9381             my $method = "set_$_";
9382            
9383             # keep in sync with Generator::Template::Plugin::XSD - maybe use
9384             # function to allow substituting via symbol table...
9385             $method =~s{[\.\-]}{_}xmsg;
9386            
9387             $self->$method( $_[1]->{ $_ } ); # ( $args_of->{ $_ } );
9388             }
9389             : $_ =~ m{ \A # beginning of string
9390             xmlns # xmlns
9391             }xms # get_elements is inlined for performance.
9392             ? ()
9393             : do {
9394             croak "unknown field $_ in $class. Valid fields are:\n"
9395             . join(', ', @{ $ELEMENTS_FROM{ $class } }) . "\n"
9396             . "Structure given:\n" . Dumper @_ };
9397             } keys %{ $_[1] }; # %$args_of;
9398             return $self;
9399             };
9400            
9401             # this _serialize method works fine for <all> and <sequence>
9402             # complextypes, as well as for <restriction><all> or
9403             # <restriction><sequence>, and attribute sets.
9404             #
9405             # But what about choice, extension ?
9406             #
9407             # Triggers XML attribute serialization if the options hash ref contains
9408             # a attr element with a true value.
9409             *{ "$class\::_serialize" } = sub {
9410             my $ident = ${ $_[0] };
9411             my $option_ref = $_[1];
9412            
9413             # return concatenated return value of serialize call of all
9414             # elements retrieved from get_elements expanding list refs.
9415             return \join q{} , map {
9416             my $element = $ATTRIBUTES_OF{ $class }->{ $_ }->{ $ident };
9417            
9418             # do we have some content
9419             if (defined $element) {
9420             $element = [ $element ] if not ref $element eq 'ARRAY';
9421             # from 2.00.09 on $NAMES_OF is filled - use || $_; for
9422             # backward compatibility
9423             my $name = $NAMES_OF{$class}->{$_} || $_;
9424            
9425             # get element's class for comparing with elements
9426             my $element_class = $CLASSES_OF{$class}->{$_};
9427            
9428             my $target_namespace = $_[0]->get_xmlns();
9429             map {
9430             my %type_info = ($element_class ne ref $_)
9431             ? (derived => 1)
9432             : ();
9433            
9434             # serialize element elements with their own serializer
9435             # but name them like they're named here.
9436             # TODO: check. element ref="" has a name???
9437             if ( $_->isa( 'SOAP::WSDL::XSD::Typelib::Element' ) ) {
9438             # serialize elements of different namespaces
9439             # with namespace declaration
9440             ($target_namespace ne $_->get_xmlns())
9441             ? $_->serialize({ name => $name, qualified => 1, %type_info })
9442             : $_->serialize({ name => $name
9443             , %type_info
9444             });
9445             }
9446             # serialize complextype elments (of other types) with their
9447             # serializer, but add element tags around.
9448             else {
9449             # TODO: check whether we have to handle
9450             # types from different namespaces special, too
9451             if (!defined $ELEMENT_FORM_QUALIFIED_OF{ $class }
9452             or $ELEMENT_FORM_QUALIFIED_OF{ $class }
9453             ) {
9454             # handle types from different namespaces
9455             #
9456             # serialize with last namespace put on stack
9457             # if the last namespace is a change from the
9458             # before-last
9459             #
9460             if (
9461             exists $option_ref->{ xmlns_stack }
9462             && (scalar @{ $option_ref->{ xmlns_stack } } >= 2)
9463             && ($option_ref->{ xmlns_stack }->[-1] ne $option_ref->{ xmlns_stack }->[-2])) {
9464             # warn "New namespace: ", $option_ref->{ xmlns_stack }->[-1];
9465             join q{}, $_->start_tag({ name => $name ,
9466             xmlns => $option_ref->{ xmlns_stack }->[-1],
9467             %{ $option_ref }, %type_info })
9468             , $_->serialize({ %{ $option_ref }, %type_info })
9469             , $_->end_tag({ name => $name , %{ $option_ref } });
9470             }
9471             else {
9472             # hack to get UPS wsdl files working
9473             # the commom:Request element uses <Request> for all subtags
9474             # Andrew Baerg - Oct 6, 2010
9475             if ($name && $option_ref->{name}) {
9476             #warn "deleting option_ref->{name} for $name: [$option_ref->{name}]";
9477             delete $option_ref->{name};
9478             }
9479            
9480             join q{}, $_->start_tag({ name => $name , %{ $option_ref }, %type_info })
9481             , $_->serialize({ %{ $option_ref }, %type_info })
9482             , $_->end_tag({ name => $name , %{ $option_ref } });
9483             }
9484             }
9485             else {
9486             # in elementFormDefault="unqualified" mode,
9487             # the serialize method has to set
9488             # xmnlns="" on all elements inside a ComplexType
9489             #
9490             # Other serializers usually use prefixes
9491             # for "unqualified" and just omit all prefixes
9492             # for inner elements
9493            
9494             # check whether we "had" a xmlns around
9495             my $set_xmlns = delete $option_ref->{xmlns};
9496            
9497             # serialize start tag with xmlns="" if out parent
9498             # did not do that
9499             join q{}, $_->start_tag({
9500             name => $name,
9501             %{ $option_ref },
9502             %type_info,
9503             (! defined $set_xmlns)
9504             ? (xmlns => "")
9505             : ()
9506             })
9507             # add xmlns = "" to child serialize options
9508             # to avoid putting xmlns="" everywhere
9509             , $_->serialize({ %{$option_ref}, xmlns => "" })
9510             , $_->end_tag({ name => $name , %{ $option_ref } });
9511             }
9512             }
9513             } @{ $element }
9514             }
9515             else {
9516             q{};
9517             }
9518             } (@{ $ELEMENTS_FROM{ $class } });
9519             };
9520            
9521             # put hidden complex serializer into class
9522             # ... but not for AttributeSet classes
9523             if ( ! $class->isa('SOAP::WSDL::XSD::Typelib::AttributeSet')) {
9524             *{ "$class\::serialize" } = \&__serialize_complex;
9525             };
9526             }
9527            
9528             sub _set_element_form_qualified {
9529             $ELEMENT_FORM_QUALIFIED_OF{ $_[0] } = $_[1];
9530             }
9531            
9532             # Just as fallback: return no attribute set class as default.
9533             # Subclasses may override
9534             sub __get_attr_class {};
9535            
9536             # hidden complex serializer
9537             sub __serialize_complex {
9538             # we work on @_ for performance.
9539             $_[1] ||= {}; # $option_ref
9540            
9541             push @{ $_[1]->{ xmlns_stack } }, $_[0]->get_xmlns();
9542            
9543             # get content first (pass by reference to avoid copying)
9544             my $content_ref = $_[0]->_serialize($_[1]); # option_ref
9545            
9546             pop @{ $_[1]->{ xmlns_stack } };
9547            
9548             # do we have a empty element ?
9549             return $_[0]->start_tag({ %{ $_[1] }, empty => 1 })
9550             if not length ${ $content_ref };
9551            
9552             return join q{}, $_[0]->start_tag($_[1]), ${ $content_ref }, $_[0]->end_tag();
9553             }
9554            
9555             sub get_xmlns {
9556             return q{}
9557             }
9558            
9559             1;
9560            
9561             __END__
9562            
9563             SOAP_WSDL_XSD_TYPELIB_COMPLEXTYPE
9564              
9565 6         14 $fatpacked{"SOAP/WSDL/XSD/Typelib/Element.pm"} =
9566             <<'SOAP_WSDL_XSD_TYPELIB_ELEMENT';
9567             package
9568             SOAP::WSDL::XSD::Typelib::Element;
9569             use strict; use warnings;
9570             use Class::Std::Fast::Storable constructor => 'none';
9571            
9572             use version; our $VERSION = qv('2.00.99_3');
9573            
9574             my %NAME;
9575             my %NILLABLE;
9576             my %REF;
9577             my %MIN_OCCURS;
9578             my %MAX_OCCURS;
9579            
9580             # TODO replace by generated methods?
9581             #
9582             # Class data - remember, we're the base class for a class factory or for
9583             # generated code...
9584             # use BLOCK: for scoping
9585             BLOCK: {
9586             my %method_lookup = (
9587             _name => \%NAME,
9588             _nillable => \%NILLABLE,
9589             _ref => \%REF,
9590             _minOccurs => \%MIN_OCCURS,
9591             _maxOccurs => \%MAX_OCCURS,
9592             );
9593            
9594             # create getters / setters for all elements' class data
9595             no strict qw(refs);
9596             while (my ($name, $value) = each %method_lookup ) {
9597             *{ "__set$name" } = sub {
9598             @_ or die "Cannot call __set$name without parameter";
9599             my $class = ref $_[0] || $_[0];
9600             $value->{ $class } = $_[1];
9601             };
9602             *{ "__get$name" } = sub {
9603             @_ or die "Cannot call __set$name as function";
9604             my $class = ref $_[0] || $_[0];
9605             return $value->{ $class };
9606             };
9607             }
9608             };
9609            
9610            
9611             # use $_[0] and $_[1] for speed.
9612            
9613             sub start_tag {
9614             # my ($self, $opt, $value) = @_;
9615             my $ending = ($_[1]->{ empty }) ? '/>' : '>';
9616             my @attr_from = ();
9617            
9618             if ($_[1]->{ nil }) {
9619             return q{} if not $NILLABLE{ ref $_[0] };
9620             push @attr_from, q{ xsi:nil="true"};
9621             $ending = '/>';
9622             }
9623            
9624             # add xmlns if requested
9625             if (delete $_[1]->{qualified}) {
9626             push @attr_from, q{ xmlns="} . $_[0]->get_xmlns() . q{"};
9627             }
9628            
9629             # add xsi:type if requested
9630             if (delete $_[1]->{derived}) {
9631             push @attr_from, q{ xsi:type="} . $_[0]->get_xmltype() . q{"};
9632             }
9633            
9634             push @attr_from, $_[0]->serialize_attr();
9635            
9636             # do we need to check for name ? Element ref="" should have it's own
9637             # start_tag. If we don't need to check, we can speed things up
9638             return join q{}, "<$_[1]->{ name }" , @attr_from , $ending if $_[1]->{ name };
9639             return join q{}, "<$NAME{ ref $_[0]}" , @attr_from , $ending;
9640             }
9641            
9642             # use $_[0] and $_[1] for speed.
9643             #
9644             # read it as:
9645             #
9646             # my ($self, $opt) = @_;
9647             # my $class = ref $self;
9648             # return "</$opt->{name}>" if $opt->{name};
9649             # return "</"$NAME{$class}>";
9650             #
9651             # do we need to check for name ? Element ref="" should have it's own
9652             # end_tag. If we don't need to check, we can speed things up by defining
9653             # end tag with () prototype - perl will inline it for us if we do...
9654             sub end_tag {
9655             return "</$_[1]->{name}>" if $_[1]->{name};
9656             return "</$NAME{ ref $_[0] }>";
9657             }
9658            
9659             1;
9660            
9661              
9662            
9663             SOAP_WSDL_XSD_TYPELIB_ELEMENT
9664              
9665 6         17 $fatpacked{"SOAP/WSDL/XSD/Typelib/SimpleType.pm"} =
9666             <<'SOAP_WSDL_XSD_TYPELIB_SIMPLETYPE';
9667             package
9668             SOAP::WSDL::XSD::Typelib::SimpleType;
9669             use strict; use warnings;
9670             use SOAP::WSDL::XSD::Typelib::Builtin;
9671            
9672             use version; our $VERSION = qv('2.00.99_3');
9673            
9674             package
9675             SOAP::WSDL::XSD::Typelib::SimpleType::restriction;
9676             use strict;
9677             use SOAP::WSDL::XSD::Typelib::Builtin;
9678             use base qw(SOAP::WSDL::XSD::Typelib::SimpleType);
9679            
9680             use version; our $VERSION = qv('2.00.99_3');
9681            
9682             1;
9683             __END__
9684            
9685            
9686             SOAP_WSDL_XSD_TYPELIB_SIMPLETYPE
9687              
9688 6         12 $fatpacked{"SOAP/WSDL/XSD/WhiteSpace.pm"} = <<'SOAP_WSDL_XSD_WHITESPACE';
9689             package
9690             SOAP::WSDL::XSD::WhiteSpace;
9691             use strict;
9692             use warnings;
9693             use Class::Std::Fast::Storable constructor => 'none';
9694             use base qw(SOAP::WSDL::Base);
9695            
9696             use version; our $VERSION = qv('2.00.99_3');
9697            
9698             #<pattern value="">
9699            
9700             # id provided by Base
9701             # name provided by Base
9702             # annotation provided by Base
9703            
9704             # may be defined as atomic simpleType
9705             my %value_of :ATTR(:name<value> :default<()>);
9706            
9707             1;
9708             SOAP_WSDL_XSD_WHITESPACE
9709              
9710 6         61627 s/^ //mg for values %fatpacked;
9711              
9712             unshift @INC, sub {
9713 182 100       1132755 if (my $fat = $fatpacked{$_[1]}) {
9714 6 50   6   271 open my $fh, '<', \$fat
  6         41  
  6         9  
  6         145  
9715             or die
9716             "FatPacker error loading $_[1] (could be a perl installation issue?)";
9717 6         183424 return $fh;
9718             }
9719 176         240642 return;
9720 6         440 };
9721              
9722             }
9723              
9724 6     6   184 use SOAP::WSDL '2.00.99_3';
  6         6978  
  6         40  
9725              
9726             1;
9727              
9728             __END__
9729              
9730             =pod
9731              
9732             =encoding UTF-8
9733              
9734             =head1 NAME
9735              
9736             Shipment::SOAP::WSDL
9737              
9738             =head1 VERSION
9739              
9740             version 2.00
9741              
9742             =head1 AUTHOR
9743              
9744             Andrew Baerg <baergaj@cpan.org>
9745              
9746             =head1 COPYRIGHT AND LICENSE
9747              
9748             This software is copyright (c) 2013 by Andrew Baerg.
9749              
9750             This is free software; you can redistribute it and/or modify it under
9751             the same terms as the Perl 5 programming language system itself.
9752              
9753             =cut