From 25548e62966acb6e9242b3ee0cb280594a8d429b Mon Sep 17 00:00:00 2001 From: Martin Kutter Date: Fri, 20 Jul 2007 05:38:01 -0800 Subject: [PATCH] import SOAP-WSDL 2.00_06 from CPAN git-cpan-module: SOAP-WSDL git-cpan-version: 2.00_06 git-cpan-authorid: MKUTTER git-cpan-file: authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_06.tar.gz --- Build.PL | 21 +- CHANGES | 58 +-- HACKING | 31 +- MANIFEST | 6 +- META.yml | 12 +- README | 2 - lib/SOAP/WSDL/Base.pm | 118 ++++-- lib/SOAP/WSDL/Binding.pm | 116 +++-- lib/SOAP/WSDL/Client.pm | 34 +- lib/SOAP/WSDL/Definitions.pm | 231 ++++++++-- lib/SOAP/WSDL/Expat/MessageParser.pm | 201 +++++++++ lib/SOAP/WSDL/Expat/MessageStreamParser.pm | 206 +++++++++ lib/SOAP/WSDL/OpMessage.pm | 5 +- lib/SOAP/WSDL/Parser.pod | 213 ++++++++++ lib/SOAP/WSDL/Part.pm | 73 ++-- lib/SOAP/WSDL/Port.pm | 33 +- lib/SOAP/WSDL/SAX/MessageHandler.pm | 132 +----- lib/SOAP/WSDL/SAX/WSDLHandler.pm | 170 ++++---- lib/SOAP/WSDL/Service.pm | 7 +- lib/SOAP/WSDL/XSD/ComplexType.pm | 176 +++++--- lib/SOAP/WSDL/XSD/Element.pm | 122 ++++-- lib/SOAP/WSDL/XSD/Primitive.pm | 7 +- lib/SOAP/WSDL/XSD/SimpleType.pm | 64 +-- .../WSDL/XSD/Typelib/Builtin/anySimpleType.pm | 10 +- lib/SOAP/WSDL/XSD/Typelib/Builtin/boolean.pm | 35 +- lib/SOAP/WSDL/XSD/Typelib/Builtin/int.pm | 22 +- lib/SOAP/WSDL/XSD/Typelib/Builtin/integer.pm | 24 +- lib/SOAP/WSDL/XSD/Typelib/Builtin/long.pm | 23 +- lib/SOAP/WSDL/XSD/Typelib/Builtin/string.pm | 41 +- lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm | 222 +++++----- lib/SOAP/WSDL/XSD/Typelib/Element.pm | 9 +- t/002_sax.t | 7 +- t/012_element.t | 19 +- t/013_complexType.t | 6 +- t/014_sax_typelib.t | 53 ++- t/016_client_object.t | 8 +- t/017_generator.t | 401 ++++++++++++++++++ t/020_storable.t | 3 +- t/Expat/01_expat.t | 62 +++ t/SOAP/WSDL/03_complexType-choice.t | 10 - t/SOAP/WSDL/11_helloworld.NET.t | 2 - t/SOAP/WSDL/97_pod.t | 27 -- t/SOAP/WSDL/XSD/Typelib/Builtin/001_string.t | 11 +- t/lib/MyComplexType.pm | 4 +- t/lib/MyElement.pm | 34 +- 45 files changed, 2227 insertions(+), 844 deletions(-) create mode 100644 lib/SOAP/WSDL/Expat/MessageParser.pm create mode 100644 lib/SOAP/WSDL/Expat/MessageStreamParser.pm create mode 100644 lib/SOAP/WSDL/Parser.pod create mode 100644 t/017_generator.t create mode 100644 t/Expat/01_expat.t delete mode 100644 t/SOAP/WSDL/97_pod.t diff --git a/Build.PL b/Build.PL index 520f834..f0eaeb5 100644 --- a/Build.PL +++ b/Build.PL @@ -2,17 +2,21 @@ use Module::Build; Module::Build->new( dist_abstract => 'SOAP with WSDL support', dist_name => 'SOAP-WSDL', - dist_version => '2.00_05', + dist_version => '2.00_06', module_name => 'SOAP::WSDL', license => 'artistic', requires => { 'Class::Std' => q/v0.0.8/, 'Class::Std::Storable' => 0, - 'SOAP::Lite' => 0, - 'XML::XPath' => 0, - 'XML::LibXML' => 0, - 'XML::SAX::Base' => 0, - 'XML::SAX::ParserFactory' => 0, + 'SOAP::Lite' => 0, + 'List::Util' => 0, + 'File::Basename' => 0, + 'File::Path' => 0, + 'XML::XPath' => 0, + 'XML::LibXML' => 0, + 'XML::SAX::Base' => 0, + 'XML::SAX::ParserFactory' => 0, + 'XML::Parser::Expat' => 0, }, buildrequires => { 'Benchmark' => 0, @@ -21,14 +25,17 @@ Module::Build->new( 'SOAP::Lite' => 0, 'Class::Std' => 0.0.8, 'Class::Std::Storable' => 0, + 'List::Util' => 0, + 'File::Basename' => 0, + 'File::Path' => 0, 'XML::XPath' => 0, 'XML::Simple' => 0, 'XML::LibXML' => 0, + 'XML::Parser::Expat' => 0, 'XML::SAX::Base' => 0, 'XML::SAX::ParserFactory' => 0, 'Pod::Simple::Text' => 0, 'XML::SAX::ParserFactory' => 0, - }, recursive_test_files => 1, )->create_build_script; diff --git a/CHANGES b/CHANGES index c6faa37..89e6e47 100644 --- a/CHANGES +++ b/CHANGES @@ -1,57 +1 @@ -$Log: CHANGES,v $ - -Revision 1.19 2004/07/27 13:00:03 lsc -- added missing test file - -Revision 1.18 2004/07/16 07:43:05 lsc -fixed test scripts for windows - -Revision 1.17 2004/07/05 08:19:49 lsc -- added wsdl_checkoccurs - -Revision 1.16 2004/07/04 09:01:14 lsc -- change element lookup from find('/definitions') and find('wsdl:definitions') to find('/*[1]') to process arbitrary default (wsdl) namespaces correctly -- fixed test output in test 06 - -Revision 1.15 2004/07/02 12:28:31 lsc -- documentation update -- cosmetics - -Revision 1.14 2004/07/02 10:53:36 lsc -- API change: - - call now behaves (almost) like SOAP::Lite::call - - call() takes a list (hash) as second argument - - call does no longer support the "dispatch" option - - dispatching calls can be suppressed by passing - "no_dispatch => 1" to new() - - dispatching calls can be suppressed by calling - $soap->no_dispatch(1); - and re-enabled by calling - $soap->no_dispatch(0); -- Updated test skripts to reflect API change. - -Revision 1.13 2004/06/30 12:08:40 lsc -- added IServiceInstance (ecmed) to acceptance tests -- refined documentation - -Revision 1.12 2004/06/26 14:13:29 lsc -- refined file caching -- added descriptive output to test scripts - -Revision 1.11 2004/06/26 07:55:40 lsc -- fixed "freeze" caching bug -- improved test scripts to test file system caching (and show the difference) - -Revision 1.10 2004/06/26 06:30:33 lsc -- added filesystem caching using Cache::FileCache - -Revision 1.9 2004/06/24 12:27:23 lsc -Cleanup - -Revision 1.8 2004/06/11 19:49:15 lsc -- moved .t files to more self-describing names -- changed WSDL.pm to accept AXIS wsdl files -- implemented XPath query result caching on all absolute queries - -Revision 1.7 2004/06/07 13:01:16 lsc -added changelog to pod +See perldoc SOAP::WSDL \ No newline at end of file diff --git a/HACKING b/HACKING index 5ea3323..d72d385 100644 --- a/HACKING +++ b/HACKING @@ -1,7 +1,7 @@ Development of SOAP::WSDL takes place on sourceforge.net. There's a svn repository available at -https://svn.sourceforge.net/svnroot/soap-wsdl +https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl Engagement in the further development of this module is highly encouraged - many people have already contributed, and many more probably will. @@ -14,13 +14,36 @@ you as co-author. The (my) current roadmap for SOAP::WSDL is: 1.2*: Bugfixes and support for more XSD variants - 1.3: Bindings support Development of the 1.* tree has stopped - I won't get past 1.2x anymore... 2.*: WSDL -> Perl Class factory with offline WSDL processing - -May 2007, + +2.01 +- WSDL support for the most common type definitions +- Online-facility (SOAP::WSDL) using WSDL object tree directly +- usable code generator +- full namespace support when processing WSDL +- high performance when parsing WSDL messages - get nearly as fast as + XML::Simple... + +2.02 +- Support for Apache-SOAP datatypes +- support for embedded atomic simpleType/complexType definitions +- Caching of WSDL object tree + generated code (when using SOAP::WSDL). +- Online-facility (SOAP::WSDL) using code generator via cache directory + +Somewhere on the TODO list (in no particular order): + +- validation +- typemaps for use with the type="tns:MyComplexType" XML attribute +- external entities support when parsing WSDL +- support all these XML Schema variants +- support creating XML Schmema definitions via SOAP::WSDL::XSD::* ('minimal conformant') +- support other Schema definition languages than XML::Schema (maybe RelaxNG?) +- factor out SOAP::WSDL::XSD into it's own namespace (maybe just XSD ?) + +July 2007, Martin Kutter \ No newline at end of file diff --git a/MANIFEST b/MANIFEST index e33f20a..df4092b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -8,9 +8,12 @@ lib/SOAP/WSDL/Client.pm lib/SOAP/WSDL/Client/Base.pm lib/SOAP/WSDL/Definitions.pm lib/SOAP/WSDL/Envelope.pm +lib/SOAP/WSDL/Expat/MessageParser.pm +lib/SOAP/WSDL/Expat/MessageStreamParser.pm lib/SOAP/WSDL/Message.pm lib/SOAP/WSDL/Operation.pm lib/SOAP/WSDL/OpMessage.pm +lib/SOAP/WSDL/Parser.pod lib/SOAP/WSDL/Part.pm lib/SOAP/WSDL/Port.pm lib/SOAP/WSDL/PortType.pm @@ -96,6 +99,7 @@ t/013_complexType.t t/014_sax_typelib.t t/015_to_typemap.t t/016_client_object.t +t/017_generator.t t/020_storable.t t/098_pod.t t/acceptance/results/03_complexType-all.xml @@ -123,6 +127,7 @@ t/acceptance/wsdl/contributed/ETest.wsdl t/acceptance/wsdl/contributed/OITest.wsdl t/acceptance/wsdl/contributed/tools.wsdl t/acceptance/wsdl/email_account.wsdl +t/Expat/01_expat.t t/lib/MyComplexType.pm t/lib/MyElement.pm t/lib/MySimpleType.pm @@ -147,5 +152,4 @@ t/SOAP/WSDL/05_simpleType-union.t t/SOAP/WSDL/10_performance.t t/SOAP/WSDL/11_helloworld.NET.t t/SOAP/WSDL/12_binding.pl -t/SOAP/WSDL/97_pod.t t/SOAP/WSDL/XSD/Typelib/Builtin/001_string.t diff --git a/META.yml b/META.yml index da20b9e..ee07e95 100644 --- a/META.yml +++ b/META.yml @@ -1,14 +1,18 @@ --- name: SOAP-WSDL -version: 2.00_05 +version: 2.00_06 author: abstract: SOAP with WSDL support license: artistic requires: Class::Std: v0.0.8 Class::Std::Storable: 0 + File::Basename: 0 + File::Path: 0 + List::Util: 0 SOAP::Lite: 0 XML::LibXML: 0 + XML::Parser::Expat: 0 XML::SAX::Base: 0 XML::SAX::ParserFactory: 0 XML::XPath: 0 @@ -33,6 +37,10 @@ provides: file: lib/SOAP/WSDL/Definitions.pm SOAP::WSDL::Envelope: file: lib/SOAP/WSDL/Envelope.pm + SOAP::WSDL::Expat::MessageParser: + file: lib/SOAP/WSDL/Expat/MessageParser.pm + SOAP::WSDL::Expat::MessageStreamParser: + file: lib/SOAP/WSDL/Expat/MessageStreamParser.pm SOAP::WSDL::Message: file: lib/SOAP/WSDL/Message.pm SOAP::WSDL::OpMessage: @@ -47,8 +55,6 @@ provides: file: lib/SOAP/WSDL/PortType.pm SOAP::WSDL::SAX::MessageHandler: file: lib/SOAP/WSDL/SAX/MessageHandler.pm - SOAP::WSDL::SAX::WSDLHandler: - file: lib/SOAP/WSDL/SAX/WSDLHandler.pm SOAP::WSDL::SOAP::Typelib::Fault11: file: lib/SOAP/WSDL/SOAP/Typelib/Fault11.pm SOAP::WSDL::Service: diff --git a/README b/README index 4d44188..7582705 100644 --- a/README +++ b/README @@ -1,4 +1,2 @@ This is a developer release - everything may (and most things will) change. -You should not expect the SOAP::WSDL to survive - it will probably be replaced -by SOAP::WSDL::Client. \ No newline at end of file diff --git a/lib/SOAP/WSDL/Base.pm b/lib/SOAP/WSDL/Base.pm index 1e06d82..eb68107 100644 --- a/lib/SOAP/WSDL/Base.pm +++ b/lib/SOAP/WSDL/Base.pm @@ -3,11 +3,19 @@ use strict; use warnings; use Carp; use Class::Std::Storable; +use List::Util qw(first); my %id_of :ATTR(:name :default<()>); my %name_of :ATTR(:name :default<()>); my %targetNamespace_of :ATTR(:name :default<()>); my %xmlns_of :ATTR(:name :default<{}>); +my %parent_of :ATTR(:name :default<()>); + +sub DEMOLISH { + my $self = shift; + # delete upward references + delete $parent_of{ ident $self }; +} sub STORABLE_freeze_pre :CUMULATIVE {}; sub STORABLE_freeze_post :CUMULATIVE {}; @@ -20,14 +28,18 @@ sub STORABLE_thaw_post :CUMULATIVE { return $_[0] }; sub AUTOMETHOD { my ($self, $ident, @values) = @_; my $subname = $_; # Requested subroutine name is passed via $_ - + # we're called as $self->push_something(@values); if ($subname =~s{^push_}{}xms) { - # we're not paranoid - we could be checking get_subname, too my $getter = "get_$subname"; - my $setter = "set_$subname"; - croak "no set accessor found for push_$subname" - if not ($self->can( $setter )); + my $setter = "set_$subname"; + ## Checking here is paranoid - will fail fatally if + ## there is no setter... + ## And we would have to check getters, too. + ## Maybe do it the Conway way via the Symbol table... + ## ... can is way slow... + # croak "no set accessor found for push_$subname" + # if not ($self->can( $setter )); return sub { no strict qw(refs); my $old_value = $self->$getter(); @@ -42,12 +54,11 @@ sub AUTOMETHOD { # we're called as $obj->find_something($ns, $key) elsif ($subname =~s {^find_}{get_}xms) { return sub { - my @found_at = grep { + return first { $_->get_targetNamespace() eq $values[0] && $_->get_name() eq $values[1] } @{ $self->$subname() }; - return $found_at[0]; } } elsif ($subname =~s {^first_}{get_}xms) { @@ -61,45 +72,98 @@ sub AUTOMETHOD { croak "$subname not found in class " . (ref $self || $self); } -#sub to_string :STRINGIFY { -# $_[0]->_DUMP(); -#} - sub init { - my $self = shift; - my @args = @_; - foreach my $value (@args) - { - die $value if (not defined ($value->{ Name })); - if ($value->{ Name } =~m{^xmlns\:}xms) { + my $self = shift; + my @args = @_; + foreach my $value (@args) + { + die $value if (not defined ($value->{ Name })); + if ($value->{ Name } =~m{^xmlns\:}xms) { die $xmlns_of{ ident $self } if ref $xmlns_of{ ident $self } ne 'HASH'; $xmlns_of{ ident $self }->{ $value->{ Value } } = $value->{ LocalName }; - next; - } + next; + } elsif ($value->{ Name } =~m{^xmlns$}xms) { # just ignore xmlns = for now # TODO handle xmlns correctly - maybe via setting a prefix ? next; } - my $name = $value->{ LocalName }; - my $method = "set_$name"; - $self->$method( $value->{ Value } ) if ( $method ); - } + my $name = $value->{ LocalName }; + my $method = "set_$name"; + $self->$method( $value->{ Value } ) if ( $method ); + } return $self; } sub add_namespace { - my ($self, $uri, $prefix ) = @_; - return unless $uri; - $self->{ namespace } ||= {}; - $self->{ namespace }->{ $uri } = $prefix; + my ($self, $uri, $prefix ) = @_; + return unless $uri; + $self->{ namespace } ||= {}; + $self->{ namespace }->{ $uri } = $prefix; } sub to_typemap { warn "to_typemap"; return q{}; } + +sub toClass { + my $self = shift; + warn 'toClass is deprecated and will be removed before reaching 2.01 - ' + . 'use to_class instead (' . caller() . ')'; + $self->to_class(@_); +} + +sub to_class { + my $self = shift; + my $opt = shift; + my $template = shift; + + $opt->{ base_path } ||= '.'; + + my $element_prefix = $opt->{ element_prefix } || $opt->{ prefix }; + my $type_prefix = $opt->{ type_prefix } || $opt->{ prefix }; + + if (($type_prefix) && ($type_prefix !~m{ :: $ }xms ) ) { + warn 'type_prefix should end with "::"'; + $type_prefix .= '::'; + } + + if (($element_prefix) && ($element_prefix !~m{ :: $ }xms) ) { + warn 'element_prefix should end with "::"'; + $element_prefix .= '::'; + } + + # Be careful: a Element may be ComplexType, too + # (but not vice versa) + my $prefix = $self->isa('SOAP::WSDL::XSD::Element') + ? $element_prefix + : $type_prefix; + + die 'No prefix specified' if not $prefix; + + my $filename = $prefix . $self->get_name() . '.pm'; + $filename =~s{::}{/}xmsg; + + my $output = $opt->{ output } || $filename; + require Template; + my $tt = Template->new( + RELATIVE => 1, + OUTPUT_PATH => $opt->{ base_path }, + ); + + my $code = $tt->process( \$template, { + element_prefix => $element_prefix, + type_prefix => $type_prefix, + self => $self, + nsmap => { reverse %{ $opt->{ wsdl }->get_xmlns() } }, + structure => $self->explain( { wsdl => $opt->{ wsdl } } ), + }, + $output + ) + or die $tt->error(); +} 1; diff --git a/lib/SOAP/WSDL/Binding.pm b/lib/SOAP/WSDL/Binding.pm index 517f01d..f082030 100644 --- a/lib/SOAP/WSDL/Binding.pm +++ b/lib/SOAP/WSDL/Binding.pm @@ -8,45 +8,44 @@ my %operation_of :ATTR(:name :default<()>); my %type_of :ATTR(:name :default<()>); my %transport_of :ATTR(:name :default<()>); my %style_of :ATTR(:name