diff --git a/Build.PL b/Build.PL index cc704e5..d7817ee 100644 --- a/Build.PL +++ b/Build.PL @@ -4,13 +4,13 @@ $build = Module::Build->new( create_makefile_pl => 'passthrough', dist_abstract => 'SOAP with WSDL support', dist_name => 'SOAP-WSDL', - dist_version => '2.00_17', + dist_version => '2.00_18', module_name => 'SOAP::WSDL', license => 'artistic', requires => { 'Class::Std' => q/v0.0.8/, 'Class::Std::Storable' => 0, - 'Data::Dumper' => 0, + 'Data::Dumper' => 0, 'Date::Parse' => 0, 'Date::Format' => 0, 'File::Basename' => 0, @@ -25,7 +25,7 @@ $build = Module::Build->new( buildrequires => { 'Class::Std' => q/v0.0.8/, 'Class::Std::Storable' => 0, - 'Cwd' => 0, + 'Cwd' => 0, 'Date::Parse' => 0, 'Date::Format' => 0, 'Getopt::Long' => 0, @@ -33,7 +33,7 @@ $build = Module::Build->new( 'LWP::UserAgent' => 0, 'File::Basename' => 0, 'File::Path' => 0, - 'File::Spec' => 0, + 'File::Spec' => 0, 'Storable' => 0, 'Test::More' => 0, 'Template' => 0, diff --git a/CHANGES b/CHANGES index 4f6215b..dfc6d64 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -Release notes for SOAP::WSDL 2.00_17 +Release notes for SOAP::WSDL 2.00_18 ------- I'm proud to present a new pre-release version of SOAP::WSDL. @@ -20,7 +20,7 @@ Features: the module's internals * Thorough test suite o SOAP::WSDL is heavily regression tested, with a test coverage of - over 90%. + over 95%. * SOAP::Lite like look and feel o Where possible, SOAP::WSDL mimics SOAP::Lite's API to allow easy migrations * XML schema based class library for creating data objects @@ -33,6 +33,27 @@ Features: The following changes have been made: +2.00_18 +---- +The following features were added (the numbers in square brackets are the +tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): + + * [ 1790983 ] Create generator Plugin API + Generator factory is SOAP::WSDL::Factory::Generator + +The following bugs have been fixed (the numbers in square brackets are the +tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660921): + + * [ 1805252 ] t/SOAP/WSDL/XSD/Typelib/Builtin/004_time.t fails + The default timezone conversion has been fixed. + +The following uncategorized improvements have been made: + + * Documentation improvements + * Test updates + * readable() has been converted into a no-op, as it already had no effect + any more + 2.00_17 ---- The following features were added (the numbers in square brackets are the diff --git a/MANIFEST b/MANIFEST index cc734af..22fac4c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -48,6 +48,7 @@ lib/SOAP/WSDL/Expat/MessageParser.pm lib/SOAP/WSDL/Expat/MessageStreamParser.pm lib/SOAP/WSDL/Expat/WSDLParser.pm lib/SOAP/WSDL/Factory/Deserializer.pm +lib/SOAP/WSDL/Factory/Generator.pm lib/SOAP/WSDL/Factory/Serializer.pm lib/SOAP/WSDL/Factory/Transport.pm lib/SOAP/WSDL/Generator/Template.pm @@ -90,12 +91,12 @@ lib/SOAP/WSDL/Generator/Visitor/Typelib.pm lib/SOAP/WSDL/Generator/Visitor/Typemap.pm lib/SOAP/WSDL/Manual.pod lib/SOAP/WSDL/Manual/Glossary.pod +lib/SOAP/WSDL/Manual/Parser.pod lib/SOAP/WSDL/Manual/WS_I.pod lib/SOAP/WSDL/Manual/XSD.pod 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 @@ -262,6 +263,7 @@ t/SOAP/WSDL/Factory/Transport.t t/SOAP/WSDL/Generator/Template.t t/SOAP/WSDL/Generator/Visitor.t t/SOAP/WSDL/Generator/Visitor/Typemap.t +t/SOAP/WSDL/Generator/XCS.t t/SOAP/WSDL/Generator/XSD.t t/SOAP/WSDL/Generator/XSD_unsupported.t t/SOAP/WSDL/Transport/01_Test.t diff --git a/META.yml b/META.yml index 8fb75b3..f9a22b8 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- name: SOAP-WSDL -version: 2.00_17 +version: 2.00_18 author: [] abstract: SOAP with WSDL support license: artistic @@ -57,6 +57,9 @@ provides: file: lib/SOAP/WSDL/Expat/MessageStreamParser.pm SOAP::WSDL::Factory::Deserializer: file: lib/SOAP/WSDL/Factory/Deserializer.pm + SOAP::WSDL::Factory::Generator: + file: lib/SOAP/WSDL/Factory/Generator.pm + version: 2.00_18 SOAP::WSDL::Factory::Serializer: file: lib/SOAP/WSDL/Factory/Serializer.pm version: 2.00_17 @@ -219,6 +222,7 @@ provides: file: lib/SOAP/WSDL/XSD/Typelib/Builtin/string.pm SOAP::WSDL::XSD::Typelib::Builtin::time: file: lib/SOAP/WSDL/XSD/Typelib/Builtin/time.pm + version: 2.00_18 SOAP::WSDL::XSD::Typelib::Builtin::token: file: lib/SOAP/WSDL/XSD/Typelib/Builtin/token.pm SOAP::WSDL::XSD::Typelib::Builtin::unsignedByte: diff --git a/bin/wsdl2perl.pl b/bin/wsdl2perl.pl index 6437cee..6935601 100644 --- a/bin/wsdl2perl.pl +++ b/bin/wsdl2perl.pl @@ -5,7 +5,7 @@ use Pod::Usage; use Getopt::Long; use LWP::UserAgent; use SOAP::WSDL::Expat::WSDLParser; -use SOAP::WSDL::Generator::Template::XSD; +use SOAP::WSDL::Factory::Generator; use Term::ReadKey; my %opt = ( @@ -16,7 +16,8 @@ my %opt = ( typemap_prefix => 'MyTypemaps', interface_prefix => 'MyInterfaces', base_path => 'lib/', - proxy => undef + proxy => undef, + generator => 'XSD', ); { # a block just to scope "no warnings" @@ -57,6 +58,7 @@ GetOptions(\%opt, keep_alive user=s password=s + generator=s ) ); @@ -91,20 +93,29 @@ if ($opt{typemap_include}) { %typemap = do $opt{typemap_include}; } -my $generator = SOAP::WSDL::Generator::Template::XSD->new({ - type_prefix => $opt{ type_prefix }, - typemap_prefix => $opt{ typemap_prefix }, - element_prefix => $opt{ element_prefix }, - interface_prefix => $opt{ interface_prefix }, - OUTPUT_PATH => $opt{ base_path }, - definitions => $definitions, -}); +my $generator = SOAP::WSDL::Factory::Generator->get_generator({ type => $opt{'generator'} }); + +if (%typemap) { + if ($generator->can('set_typemap')) { + $generator->set_typemap( \%typemap ); + } + else { + warn "Typemap snippet given, but generator does not support it\n"; + } +}; + +$generator->set_type_prefix( $opt{ type_prefix }) if $generator->can('set_type_prefix'); +$generator->set_typemap_prefix( $opt{ typemap_prefix }) if $generator->can('set_typemap_prefix'); +$generator->set_element_prefix($opt{ element_prefix }) if $generator->can('set_element_prefix'); +$generator->set_interface_prefix($opt{ interface_prefix }) if $generator->can('set_interface_prefix'); +$generator->set_OUTPUT_PATH($opt{ base_path }) if $generator->can('set_OUTPUT_PATH'); +$generator->set_definitions($definitions) if $generator->can('set_definitions'); +$generator->set_wsdl($xml) if $generator->can('set_wsdl'); # start with typelib, as errors will most likely occur here... -$generator->generate_typelib(); -$generator->generate_interface(); -$generator->generate_typemap({ (%typemap) ? (typemap => \%typemap) : () }); +$generator->generate(); +__END__ =pod @@ -133,13 +144,15 @@ wsdl2perl.pl - create perl bindings for SOAP webservices. base_path b Path to create classes in. Default: . typemap_include mi File to include in typemap. Must eval() to a valid - perl hash (not a has ref !). + perl hash (not a hash ref !). proxy x HTTP(S) proxy to use (if any). wsdl2perl will also use the proxy settings specified via the HTTP_PROXY and HTTPS_PROXY environment variables. keep_alive Use http keep_alive. user Username for HTTP authentication password Password. wsdl2perl will prompt if not given. + generator g Generator to use. + Default: XSD help h Show help content =head1 DESCRIPTION diff --git a/lib/SOAP/WSDL/Expat/Message2Hash.pm b/lib/SOAP/WSDL/Expat/Message2Hash.pm index 5f6ab92..c8fcd1b 100644 --- a/lib/SOAP/WSDL/Expat/Message2Hash.pm +++ b/lib/SOAP/WSDL/Expat/Message2Hash.pm @@ -89,7 +89,7 @@ SOAP::WSDL::Expat::Message2Hash - Convert SOAP messages to perl hash refs Real fast expat based SOAP message parser. -See L for details. +See L for details. =head1 Bugs and Limitations diff --git a/lib/SOAP/WSDL/Expat/MessageParser.pm b/lib/SOAP/WSDL/Expat/MessageParser.pm index 7ee9448..ba55b2f 100644 --- a/lib/SOAP/WSDL/Expat/MessageParser.pm +++ b/lib/SOAP/WSDL/Expat/MessageParser.pm @@ -199,7 +199,7 @@ SOAP::WSDL::Expat::MessageParser - Convert SOAP messages to custom object trees Real fast expat based SOAP message parser. -See L for details. +See L for details. =head2 Skipping unwanted items @@ -234,8 +234,8 @@ This module may be used under the same terms as perl itself. $ID: $ - $LastChangedDate: 2007-10-03 20:46:56 +0200 (Mit, 03 Okt 2007) $ - $LastChangedRevision: 305 $ + $LastChangedDate: 2007-10-07 19:27:58 +0200 (Son, 07 Okt 2007) $ + $LastChangedRevision: 313 $ $LastChangedBy: kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/MessageParser.pm $ diff --git a/lib/SOAP/WSDL/Expat/MessageStreamParser.pm b/lib/SOAP/WSDL/Expat/MessageStreamParser.pm index db159f9..5fbddae 100644 --- a/lib/SOAP/WSDL/Expat/MessageStreamParser.pm +++ b/lib/SOAP/WSDL/Expat/MessageStreamParser.pm @@ -48,7 +48,7 @@ SOAP::WSDL::Expat::MessageStreamParser - Convert SOAP messages to custom object ExpatNB based parser for parsing huge documents. -See L for details. +See L for details. =head1 Bugs and Limitations @@ -68,8 +68,8 @@ This module may be used under the same terms as perl itself. $ID: $ - $LastChangedDate: 2007-10-03 20:46:56 +0200 (Mit, 03 Okt 2007) $ - $LastChangedRevision: 305 $ + $LastChangedDate: 2007-10-07 19:27:58 +0200 (Son, 07 Okt 2007) $ + $LastChangedRevision: 313 $ $LastChangedBy: kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/MessageStreamParser.pm $ diff --git a/lib/SOAP/WSDL/Factory/Generator.pm b/lib/SOAP/WSDL/Factory/Generator.pm new file mode 100644 index 0000000..eb64156 --- /dev/null +++ b/lib/SOAP/WSDL/Factory/Generator.pm @@ -0,0 +1,172 @@ +package SOAP::WSDL::Factory::Generator; +use strict; +use warnings; + +our $VERSION='2.00_18'; + +my %GENERATOR = ( + 'XSD' => 'SOAP::WSDL::Generator::Template::XSD', +); + +# class method +sub register { + my ($class, $ref_type, $package) = @_; + $GENERATOR{ $ref_type } = $package; +} + +sub get_generator { + my ($self, $args_of_ref) = @_; + + # sanity check +# die "no generator registered for generation method $args_of_ref->{ type }" +# + my $generator_class = (exists ($GENERATOR{ $args_of_ref->{ type } })) + ? $GENERATOR{ $args_of_ref->{ type } } + : $args_of_ref->{ type }; + + # load module + eval "require $generator_class" + or die "Cannot load generator $generator_class", $@; + + return $generator_class->new(); +} + +1; + +=pod + +=head1 NAME + +SOAP::WSDL::Factory:Generator - Factory for retrieving generator objects + +=head1 SYNOPSIS + + # from SOAP::WSDL::Client: + $generator = SOAP::WSDL::Factory::Generator->get_generator({ + soap_version => $soap_version, + }); + + # in generator class: + package MyWickedGenerator; + use SOAP::WSDL::Factory::Generator; + + # register as generator for SOAP1.2 messages + SOAP::WSDL::Factory::Generator->register( '1.2' , __PACKAGE__ ); + +=head1 DESCRIPTION + +SOAP::WSDL::Factory::Generator serves as factory for retrieving +generator objects for SOAP::WSDL. + +The actual work is done by specific generator classes. + +SOAP::WSDL::Generator tries to load one of the following classes: + +=over + +=item * the class registered for the scheme via register() + +=back + +=head1 METHODS + +=head2 register + + SOAP::WSDL::Generator->register('Lite', 'MyWickedGenerator'); + +Globally registers a class for use as generator class. + +=head2 get_generator + +Returns an object of the generator class for this endpoint. + +=head1 WRITING YOUR OWN GENERATOR CLASS + +=head2 Registering a generator + +Generator classes may register with SOAP::WSDL::Factory::Generator. + +Registering a generator class with SOAP::WSDL::Factory::Generator is done +by executing the following code where $version is the SOAP version the +class should be used for, and $class is the class name. + + SOAP::WSDL::Factory::Generator->register( $version, $class); + +To auto-register your transport class on loading, execute register() in +your generator class (see L above). + +=head2 Generator package layout + +Generator modules must be named equal to the generator class they contain. +There can only be one generator class per generator module. + +=head2 Methods to implement + +Generator classes must implement the following methods: + +=over + +=item * new + +Constructor. + +=item * generate + +Generate SOAP interface + +=back + +Generators may implements one or more of the following configuration +methods. All of them are tried via can() by wsdl2perl. + +=over + +=item * set_wsdl + +Set the raw WSDL XML. Implement if you have your own WSDL parser. + +=item * set_definitions + +Sets the (parsed) SOAP::WSDL::Definitions object. + +=item * set_type_prefix + +Sets the prefix for XML Schema type classes + +=item * set_element_prefix + +Sets the prefix for XML Schema element classes + +=item * set_typemap_prefix + +Sets the prefix for typemap classes (class resolvers). + +=item * set_interface_prefix + +Sets the prefix for interface classes + +=item * set_typemap + +Set user-defined typemap snippet + +=back + +=head1 LICENSE + +Copyright (c) 2004-2007 Martin Kutter. + +This file is part of SOAP-WSDL. You may distribute/modify it under the same +terms as perl itself + +=head1 AUTHOR + +Martin Kutter Emartin.kutter fen-net.deE + +=head1 REPOSITORY INFORMATION + + $Rev: 302 $ + $LastChangedBy: kutterma $ + $Id: Generator.pm 302 2007-09-30 19:25:25Z kutterma $ + $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Factory/Generator.pm $ + +=cut diff --git a/lib/SOAP/WSDL/Generator/Template.pm b/lib/SOAP/WSDL/Generator/Template.pm index 4b28700..5303f5a 100644 --- a/lib/SOAP/WSDL/Generator/Template.pm +++ b/lib/SOAP/WSDL/Generator/Template.pm @@ -18,18 +18,18 @@ my %OUTPUT_PATH_of :ATTR(:name :default<.>); sub START { my ($self, $ident, $arg_ref) = @_; - $tt_of{$ident} = Template->new( +} + +sub _process :PROTECTED { + my ($self, $template, $arg_ref, $output) = @_; + my $ident = ident $self; + my $tt = $tt_of{$ident} ||= Template->new( DEBUG => 1, EVAL_PERL => $EVAL_PERL_of{ $ident }, RECURSION => $RECURSION_of{ $ident }, INCLUDE_PATH => $INCLUDE_PATH_of{ $ident }, OUTPUT_PATH => $OUTPUT_PATH_of{ $ident }, ); -} - -sub _process :PROTECTED { - my ($self, $template, $arg_ref, $output) = @_; - my $tt = $self->get_tt(); $tt->process( $template, { definitions => $self->get_definitions, diff --git a/lib/SOAP/WSDL/Generator/Template/XSD.pm b/lib/SOAP/WSDL/Generator/Template/XSD.pm index c9a53bb..14dfcc3 100644 --- a/lib/SOAP/WSDL/Generator/Template/XSD.pm +++ b/lib/SOAP/WSDL/Generator/Template/XSD.pm @@ -9,7 +9,8 @@ use SOAP::WSDL::Generator::Visitor::Typemap; use SOAP::WSDL::Generator::Visitor::Typelib; use base qw(SOAP::WSDL::Generator::Template); -my %output_of :ATTR(:name :default<()>); +my %output_of :ATTR(:name :default<()>); +my %typemap_of :ATTR(:name :default<({})>); sub BUILD { my ($self, $ident, $arg_ref) = @_; @@ -21,6 +22,13 @@ sub BUILD { ); } +sub generate { + my $self = shift; + $self->generate_typelib(); + $self->generate_interface(); + $self->generate_typemap(); +} + sub generate_typelib { my ($self) = @_; @@ -73,7 +81,8 @@ sub generate_typemap { 'Fault/faultcode' => 'SOAP::WSDL::XSD::Typelib::Builtin::anyURI', 'Fault/faultactor' => 'SOAP::WSDL::XSD::Typelib::Builtin::TOKEN', 'Fault/faultstring' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', - 'Fault/detail' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', + 'Fault/detail' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', + %{ $typemap_of{ident $self }}, } }); for my $service (@{ $self->get_definitions->get_service }) { diff --git a/lib/SOAP/WSDL/Manual.pod b/lib/SOAP/WSDL/Manual.pod index fd90423..6afa108 100644 --- a/lib/SOAP/WSDL/Manual.pod +++ b/lib/SOAP/WSDL/Manual.pod @@ -227,7 +227,7 @@ L, L tell you how to create subclasses of XML schema types. -L will tell you how to create a typemap class. +L will tell you how to create a typemap class. =back @@ -273,7 +273,7 @@ class. This unfortunately means that you have to set the endpoint URL, too: You may, of course, decide to just hack the generated class. Be advised that subclassing might be a more appropriate solution - re-generating overwrites -your changes. +changes in interface classes. =head3 Accessing HTTPS webservices protected by certificate authentication diff --git a/lib/SOAP/WSDL/Parser.pod b/lib/SOAP/WSDL/Manual/Parser.pod similarity index 99% rename from lib/SOAP/WSDL/Parser.pod rename to lib/SOAP/WSDL/Manual/Parser.pod index 6bc8a23..5a2c612 100644 --- a/lib/SOAP/WSDL/Parser.pod +++ b/lib/SOAP/WSDL/Manual/Parser.pod @@ -2,7 +2,7 @@ =head1 NAME -SOAP::WSDL::Parser - How SOAP::WSDL parses XML messages +SOAP::WSDL::Manual::Parser - How SOAP::WSDL parses XML messages =head1 Which XML message does SOAP::WSDL parse ? diff --git a/lib/SOAP/WSDL/Manual/XSD.pod b/lib/SOAP/WSDL/Manual/XSD.pod index 405902c..7206cfb 100644 --- a/lib/SOAP/WSDL/Manual/XSD.pod +++ b/lib/SOAP/WSDL/Manual/XSD.pod @@ -2,7 +2,7 @@ =head1 NAME -SOAP::WSDL::XSD - SOAP::WSDL's XML Schema implementation +SOAP::WSDL::Manual::XSD - SOAP::WSDL's XML Schema implementation =head1 DESCRIPTION @@ -15,6 +15,32 @@ class (usually in it's own file). Atomic types are either directly included in the class of their parent's node, or as sub-package in their parent class' file. +While the implementation is still incomplete, it covers the XML schema +definitions used by most object mappers. + +=head1 USAGE + +You can use SOAP::WSDL::XSD based classes just like any perl class - you may +instantiate it, inherit from it etc. + +You should be aware, that SOAP::WSDL::XSD based classes are inside-out +classes using Class::Std, though - things you would expect from hash-based +classes like using the blessed hash ref as data storage won't work. + +Moreover, most classes override Class::Std's default constructor for speed - +you should not expect BUILD or START methods to work, unless you call them +yourself (or define a new constructor). + +All SOAP::WSDL::XSD based complexType classes allow a hash ref mathing their +data structure as only parameter to new(). You may mix hash and list refs and +objects in the structure passed to new - as long as the structure matches, it +will work fine. + +All SOAP::WSDL::XSD based simpleType (and builtin) classes accept a single +hash ref with the only key "value" and the value to be set as value. + +=head1 HOW IT WORKS + =head2 Base classes SOAP::WSDL::XSD provides a set of base classes for the construction of XML @@ -43,7 +69,14 @@ L for details. =head3 complexType construction class -For the construction of complexType classes, the +For the construction of complexType classes, the construction class +SOAP::WSDL::XSD::Typelib::ComplexType is provided. It provides a __factory +method for placing attributes in generated classes, and generating +appropriate setter/getter accessors. + +The setters are special: They handle complex data structures of any type +(meaning hash refs, list refs and objects, and any combination of them), as +long as their structure matches the expected structure. =head1 TRANSLATION RULES @@ -81,9 +114,9 @@ SOAP::WSDL::XSD::Typelib::Element and from the base type of the atomic type. Element atomic Type base class base class - ^ ^ - | | - ------------- + ^ ^ + | | + -------------- | element simpleType class @@ -95,9 +128,9 @@ SOAP::WSDL::XSD::Typelib::ComplexType. Element complexType base class base class - ^ ^ - | | - ------------- + ^ ^ + | | + -------------- | element complexType class @@ -108,14 +141,36 @@ TODO add more elaborate description Some content models are not implemented yet. The content models implemented are described below. -=head3 complexType with "sequence" variety - =head3 complexType with "all" variety +Complex types with "all" variety inherit from +SOAP::WSDL::XSD::Typelib::ComplexType, and call it's factory method for +creating fields and accessors/mutators for the complexType's elements. + +All element's type classes are loaded. Complex type classes have a "has a" +relationship to their element fields. + +Element fields may either be element classes (for element ref="") or type +classes (for element type=""). No extra element classes are created for +a complexType's elements. + + complexType + base class + ^ + | + complexType all + ---------------- has a + element name="a" ------------> Element or type class object + element name="b" ------------> Element or type class object + The implementation for all does enforce the order of elements as described in the WSDL, even though this is not required by the XML Schema specification. +=head3 complexType with "sequence" variety + +The implementation of the "sequence" variety is the same as for all. + =head3 complexType with "choice" variety The implementation for choice currently is the same as for all - which means, @@ -130,6 +185,13 @@ no check for occurence are made. ComplexType classes with restriction variety inherit from their base type. No additional processing or content checking is performed yet. + complexType + base type class + ^ + | + complexType + restriction + Note that complexType with restriction variety classes don't exhibit their type via the xsi:type attribute yet, so they currently cannot be used as a replacement for their base type. diff --git a/lib/SOAP/WSDL/XSD/Typelib/Builtin/time.pm b/lib/SOAP/WSDL/XSD/Typelib/Builtin/time.pm index 75e9432..d9383bb 100644 --- a/lib/SOAP/WSDL/XSD/Typelib/Builtin/time.pm +++ b/lib/SOAP/WSDL/XSD/Typelib/Builtin/time.pm @@ -4,6 +4,8 @@ use warnings; use Date::Parse; use Date::Format; +our $VERSION='2.00_18'; + # Speed up. Class::Std::new is slow - and we don't need it's functionality... BEGIN { use Class::Std::Storable; @@ -40,8 +42,16 @@ sub set_value { # We leave out the optional nanoseconds part, as it would always be empty. else { # strptime sets empty values to undef - and strftime doesn't like that... - # we even need to set it to 1 to prevent a "Day '0' out of range 1..31" warning... - my @time_from = map { ! defined $_ ? 1 : $_ } strptime($_[1]); + # we even need to set it to 1 to prevent a "Day '0' out of range 1..31" warning.. + + # we need to set the current date for correct TZ conversion - + # could be daylight savings time + my @now = localtime; + my @time_from = map { my $alternative = shift @now; + ! defined $_ + ? $alternative + : $_ } strptime($_[1]); + undef $time_from[-1]; my $time_str = strftime( '%H:%M:%S%z', @time_from ); substr $time_str, -2, 0, ':'; $_[0]->SUPER::set_value($time_str); diff --git a/t/006_client.t b/t/006_client.t index 0c54c1d..26d4bd7 100644 --- a/t/006_client.t +++ b/t/006_client.t @@ -21,7 +21,6 @@ my $soap = SOAP::WSDL->new( wsdl => 'file:///' . $path .'/t/acceptance/wsdl/006_sax_client.wsdl', outputxml => 1, # required, if not set ::SOM serializer will be loaded on # call - readable => 1, )->wsdlinit(); $soap->servicename('MessageGateway'); diff --git a/t/009_data_classes.t b/t/009_data_classes.t index 4ad263f..d19a224 100644 --- a/t/009_data_classes.t +++ b/t/009_data_classes.t @@ -1,7 +1,7 @@ #!/usr/bin/perl -w use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 5; use lib 't/lib'; use lib '../lib'; use lib 'lib'; @@ -39,14 +39,12 @@ else # TODO factor out into different test my $soap = SOAP::WSDL->new( - readable => 1, wsdl => 'file:///' . $path .'/t/acceptance/wsdl/006_sax_client.wsdl', )->wsdlinit(); $soap->servicename('MessageGateway'); ok( $soap->no_dispatch( 1 ) , "Set no_dispatch" ); -ok( $soap->readable( 0 ) , "Set readable"); sub xml { q{new( wsdl => 'file://' . $path . '/../../acceptance/wsdl/03_complexType-all.wsdl', - readable =>1, ), 'Instantiated object' ); #3 diff --git a/t/SOAP/WSDL/03_complexType-choice.t b/t/SOAP/WSDL/03_complexType-choice.t index f4ac1a7..15f5250 100644 --- a/t/SOAP/WSDL/03_complexType-choice.t +++ b/t/SOAP/WSDL/03_complexType-choice.t @@ -7,6 +7,6 @@ my $soap = SOAP::WSDL->new(); TODO: { - local $TODO="implement support"; + local $TODO="implement tests"; fail "serialize choice element"; } \ No newline at end of file diff --git a/t/SOAP/WSDL/03_complexType-complexContent.t b/t/SOAP/WSDL/03_complexType-complexContent.t index 0865153..a002860 100644 --- a/t/SOAP/WSDL/03_complexType-complexContent.t +++ b/t/SOAP/WSDL/03_complexType-complexContent.t @@ -17,6 +17,6 @@ my $soap = SOAP::WSDL->new(); TODO: { - local $TODO="implement support"; + local $TODO="implement tests"; fail "serialize complexContent element"; } \ No newline at end of file diff --git a/t/SOAP/WSDL/03_complexType-element-ref.t b/t/SOAP/WSDL/03_complexType-element-ref.t index 1d9ef06..e686981 100644 --- a/t/SOAP/WSDL/03_complexType-element-ref.t +++ b/t/SOAP/WSDL/03_complexType-element-ref.t @@ -20,7 +20,6 @@ my $soap; #2 ok( $soap = SOAP::WSDL->new( wsdl => 'file://' . $path . '/../../acceptance/wsdl/03_complexType-element-ref.wsdl', - readable => 1, no_dispatch => 1, ), 'Instantiated object' ); diff --git a/t/SOAP/WSDL/04_element-simpleType.t b/t/SOAP/WSDL/04_element-simpleType.t index 7ee562d..ffe6a1c 100644 --- a/t/SOAP/WSDL/04_element-simpleType.t +++ b/t/SOAP/WSDL/04_element-simpleType.t @@ -14,14 +14,10 @@ my $soap = undef; my $path = File::Spec->rel2abs( dirname __FILE__ ); -#2 ok( $soap = SOAP::WSDL->new( wsdl => 'file:///' . $path . '/../../acceptance/wsdl/04_element-simpleType.wsdl' ), 'Instantiated object' ); -#3 -$soap->readable(1); - # won't work without - would require SOAP::WSDL::Deserializer::SOM, # which requires SOAP::Lite $soap->outputxml(1); diff --git a/t/SOAP/WSDL/05_simpleType-list.t b/t/SOAP/WSDL/05_simpleType-list.t index 2a6c27f..8f1dacb 100644 --- a/t/SOAP/WSDL/05_simpleType-list.t +++ b/t/SOAP/WSDL/05_simpleType-list.t @@ -17,7 +17,6 @@ ok( $soap = SOAP::WSDL->new( wsdl => 'file:///' . $path . '/../../acceptance/wsdl/05_simpleType-list.wsdl' ), 'Instantiated object' ); -$soap->readable(1); # won't work without - would require SOAP::WSDL::Deserializer::SOM, # which requires SOAP::Lite $soap->outputxml(1); diff --git a/t/SOAP/WSDL/05_simpleType-restriction.t b/t/SOAP/WSDL/05_simpleType-restriction.t index bfe90e3..3567303 100644 --- a/t/SOAP/WSDL/05_simpleType-restriction.t +++ b/t/SOAP/WSDL/05_simpleType-restriction.t @@ -20,7 +20,6 @@ ok( $soap = SOAP::WSDL->new( ), 'Instantiated object' ); #3 -$soap->readable(1); ok( $soap->wsdlinit( servicename => 'testService', ), 'parsed WSDL' ); diff --git a/t/SOAP/WSDL/05_simpleType-union.t b/t/SOAP/WSDL/05_simpleType-union.t index 8fae70c..980b92d 100644 --- a/t/SOAP/WSDL/05_simpleType-union.t +++ b/t/SOAP/WSDL/05_simpleType-union.t @@ -16,7 +16,6 @@ ok $soap = SOAP::WSDL->new( ), 'Instantiated object'; #3 -$soap->readable(1); ok $soap->wsdlinit(), 'parsed WSDL'; $soap->no_dispatch(1); # won't work without - would require SOAP::WSDL::Deserializer::SOM, diff --git a/t/SOAP/WSDL/Generator/XCS.t b/t/SOAP/WSDL/Generator/XCS.t new file mode 100644 index 0000000..f140a66 --- /dev/null +++ b/t/SOAP/WSDL/Generator/XCS.t @@ -0,0 +1,25 @@ +use strict; +use warnings; +use Test::More; +use File::Spec; +use File::Basename; +eval { require XML::Compile::WSDL11 } + or plan skip_all => 'Cannot test without XML::Compile::WSDL11'; + +eval { require XML::LibXML } + or plan skip_all => 'Cannot test without XML::LibXML'; + +plan skip_all => 'XML::Compile::WSDL11 is not functional yet'; + +plan tests => qw(no_plan); + +my $path = File::Spec->rel2abs( dirname __FILE__ ); + +my $libxml = XML::LibXML->new(); +my $xml = $libxml->parse_file("$path/../../../acceptance/wsdl/generator_test.wsdl"); + +my $wsdl = XML::Compile::WSDL11->new($xml); +my $schemas = $wsdl->schemas; +my $operation = $wsdl->operation('testHeader'); + +my $client = $operation->prepareClient(); diff --git a/t/SOAP/WSDL/XSD/Typelib/Builtin/time.t b/t/SOAP/WSDL/XSD/Typelib/Builtin/time.t index 5589aef..3dc82a2 100644 --- a/t/SOAP/WSDL/XSD/Typelib/Builtin/time.t +++ b/t/SOAP/WSDL/XSD/Typelib/Builtin/time.t @@ -2,6 +2,17 @@ use Test::More tests => 3; use strict; use warnings; use lib '../lib'; +use Date::Parse; +use Date::Format; + +sub timezone { + my @time = localtime; + my $tz = strftime('%z', @time); + substr $tz, -2, 0, ':'; + return $tz; +} + +my $timezone = timezone; use_ok('SOAP::WSDL::XSD::Typelib::Builtin::time'); my $obj; @@ -9,7 +20,7 @@ my $obj; $obj = SOAP::WSDL::XSD::Typelib::Builtin::time->new(); $obj->set_value( '12:23:03' ); -is $obj->get_value() , '12:23:03+01:00', 'conversion'; +is $obj->get_value() , "12:23:03$timezone", 'conversion'; $obj->set_value( '12:23:03.12345+01:00' ), ; is $obj->get_value() , '12:23:03.12345+01:00', 'no conversion'; diff --git a/t/acceptance/wsdl/generator_test.wsdl b/t/acceptance/wsdl/generator_test.wsdl index ba5b229..7300ef7 100644 --- a/t/acceptance/wsdl/generator_test.wsdl +++ b/t/acceptance/wsdl/generator_test.wsdl @@ -5,6 +5,7 @@ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns="http://schemas.xmlsoap.org/wsdl/" > @@ -197,9 +198,9 @@ - - - + + + @@ -209,8 +210,7 @@ - - + @@ -218,10 +218,8 @@ - -