From f0b3bdc20177779cab9259c51f49eecd24e139dc Mon Sep 17 00:00:00 2001 From: Martin Kutter Date: Sun, 10 Feb 2008 15:36:36 -0800 Subject: [PATCH] import SOAP-WSDL 2.00_31 from CPAN git-cpan-module: SOAP-WSDL git-cpan-version: 2.00_31 git-cpan-authorid: MKUTTER git-cpan-file: authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_31.tar.gz --- Build.PL | 7 +- Changes | 264 ++++++++++-------- MANIFEST | 9 +- META.yml | 15 +- MIGRATING | 18 +- benchmark/person_profile.pl | 11 + bin/wsdl2perl.pl | 71 +++-- lib/SOAP/WSDL.pm | 26 +- lib/SOAP/WSDL/Client/Base.pm | 59 ++-- lib/SOAP/WSDL/Deserializer/XSD.pm | 7 +- lib/SOAP/WSDL/Expat/Base.pm | 32 ++- lib/SOAP/WSDL/Expat/MessageParser.pm | 7 +- lib/SOAP/WSDL/Expat/WSDLParser.pm | 70 ++++- lib/SOAP/WSDL/Factory/Deserializer.pm | 2 +- lib/SOAP/WSDL/Factory/Serializer.pm | 6 +- lib/SOAP/WSDL/Factory/Transport.pm | 18 +- .../Template/XSD/complexType/variety.tt | 13 +- lib/SOAP/WSDL/Manual/WS_I.pod | 25 +- lib/SOAP/WSDL/Serializer/XSD.pm | 5 +- lib/SOAP/WSDL/TypeLookup.pm | 10 +- lib/SOAP/WSDL/XSD/Builtin.pm | 2 +- lib/SOAP/WSDL/XSD/ComplexType.pm | 2 +- lib/SOAP/WSDL/XSD/Element.pm | 2 +- lib/SOAP/WSDL/XSD/Typelib/Attribute.pm | 2 + lib/SOAP/WSDL/XSD/Typelib/AttributeSet.pm | 2 + lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm | 14 +- lib/SOAP/WSDL/XSD/Typelib/Element.pm | 4 +- patches/Manual.diff | 44 --- t/006_client.t | 21 +- t/016_client_object.t | 15 +- t/SOAP/WSDL.t | 4 +- t/SOAP/WSDL/02_port.t | 13 +- t/SOAP/WSDL/04_element.t | 22 +- t/SOAP/WSDL/Client.t | 28 +- t/SOAP/WSDL/Client/Base.t | 122 +++++++- t/SOAP/WSDL/Definitions.t | 32 +++ t/SOAP/WSDL/Deserializer/XSD.t | 7 +- t/SOAP/WSDL/Expat/Base.t | 13 +- t/SOAP/WSDL/Expat/MessageParser.t | 6 +- t/SOAP/WSDL/Expat/WSDLParser.t | 33 ++- t/SOAP/WSDL/Factory/Transport.t | 8 +- t/SOAP/WSDL/Generator/Template.t | 8 +- t/SOAP/WSDL/Generator/XSD.t | 9 +- t/SOAP/WSDL/PortType.t | 32 +++ t/SOAP/WSDL/Server.t | 5 + t/SOAP/WSDL/Server/CGI.t | 146 +++++++--- t/SOAP/WSDL/XSD/Attribute.t | 40 +++ t/SOAP/WSDL/XSD/Element.t | 14 +- t/SOAP/WSDL/XSD/Schema.t | 32 +++ t/SOAP/WSDL/XSD/Typelib/ComplexType.t | 83 +++--- t/acceptance/wsdl/WSDLParser-import.wsdl | 20 ++ t/acceptance/wsdl/WSDLParser-imported.wsdl | 52 ++++ t/acceptance/wsdl/generator_test.wsdl | 9 + t/acceptance/wsdl/import.xsd | 23 ++ 54 files changed, 1094 insertions(+), 450 deletions(-) create mode 100644 benchmark/person_profile.pl delete mode 100644 patches/Manual.diff create mode 100644 t/SOAP/WSDL/Definitions.t create mode 100644 t/SOAP/WSDL/PortType.t create mode 100644 t/SOAP/WSDL/XSD/Attribute.t create mode 100644 t/SOAP/WSDL/XSD/Schema.t create mode 100644 t/acceptance/wsdl/WSDLParser-import.wsdl create mode 100644 t/acceptance/wsdl/WSDLParser-imported.wsdl create mode 100644 t/acceptance/wsdl/import.xsd diff --git a/Build.PL b/Build.PL index 955aa9b..1cfa686 100644 --- a/Build.PL +++ b/Build.PL @@ -5,11 +5,11 @@ $build = Module::Build->new( create_makefile_pl => 'passthrough', dist_abstract => 'SOAP with WSDL support', dist_name => 'SOAP-WSDL', - dist_version => '2.00_29', + dist_version => '2.00_31', module_name => 'SOAP::WSDL', license => 'artistic', requires => { - # 5.6.x is way too buggy and has no unicode support + # 5.6.x is way too buggy and has no unicode support # for us. SOAP-WSDL relies on unicode (WS-I demands it) # and triggers several 5.6 bugs... 'perl' => q(5.8.0), @@ -24,6 +24,7 @@ $build = Module::Build->new( 'LWP::UserAgent' => 0, 'Template' => 0, 'Term::ReadKey' => 0, + 'URI' => 0, 'XML::Parser::Expat' => 0, }, buildrequires => { @@ -39,7 +40,7 @@ $build = Module::Build->new( 'File::Spec' => 0, 'Storable' => 0, 'Test::More' => 0, - 'Template' => 0, + 'Template' => 0, 'XML::Parser::Expat' => 0, }, recursive_test_files => 1, diff --git a/Changes b/Changes index 40cda63..0527a7d 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,4 @@ -Release notes for SOAP::WSDL 2.00_29 +Release notes for SOAP::WSDL 2.00_31 ------- I'm proud to present a new pre-release version of SOAP::WSDL. @@ -16,17 +16,17 @@ Features: o Automatically encodes perl data structures as message data o Automatically sets HTTP headers right * Efficient documentation - o SOAP::WSDL::Manual guides you at getting your work done, not at + o SOAP::WSDL::Manual guides you at getting your work done, not at the module's internals * Thorough test suite - o SOAP::WSDL is heavily regression tested, with a test coverage of - over 95% (excluding documentation - you wouldn't want to read + o SOAP::WSDL is heavily regression tested, with a test coverage of + over 95% (excluding documentation - you wouldn't want to read through it all). * 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 * High-performance XML parser - * Plugin support. SOAP::WSDL can be extended through plugins in various aspects. + * Plugin support. SOAP::WSDL can be extended through plugins in various aspects. The following plugins are supported: o Transport plugins via SOAP::WSDL::Factory::Transport o Serializer plugins via SOAP::WSDL::Factory::Serializer @@ -34,9 +34,51 @@ Features: The following changes have been made: +2.00_31 - Feb 11 2007 + +The following features were added (the numbers in square brackets are the +tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): + + * [ 1883843 ] Support wsdl:import + * [ 1883863 ] Support xsd:import + +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): +The numbers with # are CPAN RT IDs (http://rt.cpan.org/). + +The following uncategorized improvements have been made: + + * The WSDL Parser now warns about unsupported WSDL / XML schema elements + * Fixed path handling in t/006_client.t + * Removed useless ms regex flag in SOAP::WSDL::Factory::Transport + * The test suite has been improved + +2.00_30 - unreleased + +The following features were added (the numbers in square brackets are the +tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): + + * [ 1875288 ] Support XML attributes (partial) + +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): +The numbers with # are CPAN RT IDs (http://rt.cpan.org/). + + * [ 1876435 ] Test on perl-5.10 fails + * #32611 empty complexType structure classes are missing 'use Class::Std::Fast::Storable' + +The following uncategorized improvements have been made: + + * ComplexType objects now accept { foo => undef } in constructor and handle + it as non-present child element foo. + * Updated test suite + * Updated SOAP::WSDL::Client::Base to correctly handle SOAP calls with + no parameters (empty parts) + * Test on perl-5.10 fails when SOAP::Lite is not installed + 2.00_29 -The following bugs have been fixed (the numbers in square brackets are the +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): The numbers with # are CPAN RT IDs (http://rt.cpan.org/). @@ -53,13 +95,13 @@ The following uncategorized improvements have been made: 2.00_28 -The following bugs have been fixed (the numbers in square brackets are the +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): The numbers with # are CPAN RT IDs (http://rt.cpan.org/). * #32062: minor doc fixes * [ 1852988 ] Generated Interface POD is invalid - * [ 1855583 ] t/SOAP/WSDL/XSD/Typelib/ComplexType.t requires Test::Warn + * [ 1855583 ] t/SOAP/WSDL/XSD/Typelib/ComplexType.t requires Test::Warn The following uncategorized improvements have been made: @@ -67,13 +109,13 @@ The following uncategorized improvements have been made: 2.00_27 -The following features were added (the numbers in square brackets are the +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): * [ 1850793 ] Add a to_hash_ref method * [ 1844427 ] Support multiple parts in body -The following bugs have been fixed (the numbers in square brackets are the +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): The numbers with # are CPAN RT IDs (http://rt.cpan.org/). @@ -91,10 +133,10 @@ The following uncategorized improvements have been made: 2.00_26 -The following features were added (the numbers in square brackets are the +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): -The following bugs have been fixed (the numbers in square brackets are the +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): The numbers with # are CPAN RT IDs (http://rt.cpan.org/). @@ -110,25 +152,25 @@ The following uncategorized improvements have been made: --- WARNING: INCOMPATIBLE CHANGE: - SOAP::WSDL now uses Class::Std::Fast. Read the MIGRATING guide for + SOAP::WSDL now uses Class::Std::Fast. Read the MIGRATING guide for upgrading from previous versions. You probably need to re-generate all your interfaces. WARNING: INCOMPATIBLE CHANGE: - SOAP::WSDL::XSD::Typelib::anySimpleType based objects no longer serialize + SOAP::WSDL::XSD::Typelib::anySimpleType based objects no longer serialize to their XML value on stringification. - This means that strings are no longer XML-escaped when the simpleType + This means that strings are no longer XML-escaped when the simpleType containing the string is printed or used like this: my $value = "$simpleType"; - Note that ComplexType objects still serialize to their XML on - stringification. This Change is due to the demands of applications - embedding SOAP::WSDL::XSD::Typelib objects in templates - it would mean + Note that ComplexType objects still serialize to their XML on + stringification. This Change is due to the demands of applications + embedding SOAP::WSDL::XSD::Typelib objects in templates - it would mean a nasty ->get_value for every (simple) value. -The following features were added (the numbers in square brackets are the +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): * [ 1837347 ] Use Class::Std::Fast @@ -137,7 +179,7 @@ tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): for even faster XS implementations. * [ 1842436 ] Add SOAP Server -The following bugs have been fixed (the numbers in square brackets are the +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): The numbers with # are CPAN RT IDs (http://rt.cpan.org/). @@ -155,13 +197,13 @@ The following uncategorized improvements have been made: 2.00_24 --- -The following features were added (the numbers in square brackets are the +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): * [ 1832998 ] Make interface methods complain when called as class method * [ 1826833 ] listify all XSD type objects when called as @{} -The following bugs have been fixed (the numbers in square brackets are the +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): The numbers with # are CPAN RT IDs (http://rt.cpan.org/). @@ -170,7 +212,7 @@ The numbers with # are CPAN RT IDs (http://rt.cpan.org/). * [ 1828240 ] POD Defects * [ 1792348 ] 006_client.t requires SOAP::Lite (again) -The following uncategorized improvements have been made: +The following uncategorized improvements have been made: * The test suite has been improved * Documentation has been improved @@ -178,160 +220,160 @@ The following uncategorized improvements have been made: 2.00_23 --- -The following bugs have been fixed (the numbers in square brackets are the +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): * [ 1826382 ] nillable elements not serialized as xsi:nil * [ 1826337 ] Second element in complexType gets eaten up * [ 1792348 ] 006_client.t requires SOAP::Lite (again) -The following uncategorized improvements have been made: +The following uncategorized improvements have been made: * Test for complexType containing element with atomic simpleType added 2.00_22 ---- -The following bugs have been fixed (the numbers in square brackets are the +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): * [ 1817697 ] Dots in service/port names lead to broken interfaces * [ 1817699 ] Templates not found on all OS -The following uncategorized improvements have been made: +The following uncategorized improvements have been made: - * Code cleanup. The XSD library has been cleaned up a bit. Should result + * Code cleanup. The XSD library has been cleaned up a bit. Should result in a minor speedup in serializing and deserializing XML messages, 2.00_21 - not released ---- -The following bugs have been fixed (the numbers in square brackets are the +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): * [ 1810058 ] .tt's pod indexed on CPAN (again) * [ 1809284 ] Rename SOAP::WSDL::Deserializer::SOAP11 to ::XSD -The following uncategorized improvements have been made: +The following uncategorized improvements have been made: - * Requires at least perl 5.8.0. This is due to a bug in perls before - + * Requires at least perl 5.8.0. This is due to a bug in perls before - see http://aspn.activestate.com/ASPN/Mail/Message/perl5-porters/929746 2.00_20 ---- -The following features were added (the numbers in square brackets are the +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): * [ 1815646 ] Only include last part of port name in interface * [ 1815648 ] Methods with empty body cannot be called as ->method() * [ 1815651 ] Empty complexType definitions not supported - -The following bugs have been fixed (the numbers in square brackets are the + +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): * [ 1815643 ] ComplexTypes cannot be freezed/thawed -The following uncategorized improvements have been made: +The following uncategorized improvements have been made: * WSDL definitions are decoded into utf8 * fixed tests to use correct path on windows 2.00_19 ---- -The following features were added (the numbers in square brackets are the +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): * [ 1810395 ] Implement complexType complexContent extension -The following bugs have been fixed (the numbers in square brackets are the +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): * [ 1813144 ] Typemap not used in interface class * [ 1810058 ] .tt's pod indexed on CPAN -The following uncategorized improvements have been made: +The following uncategorized improvements have been made: * Documentation improvements 2.00_18 ---- -The following features were added (the numbers in square brackets are the +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 +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: +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 + * 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 +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): -The following bugs have been fixed (the numbers in square brackets are the +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): * [ 1772617 ] SOAP Header not working - Added header support. Currently, SOAP headers are only supported with + Added header support. Currently, SOAP headers are only supported with the SOM or the XSD (SOAP11) serializer. * [ 1805238 ] Tests in t/SOAP/WSDL don't work when run from t/ * [ 1805241 ] explain() broken in SOAP::WSDL explain has been removed from SOAP::WSDL - -The following uncategorized improvements have been made: - * Added limited support for complexType complexContent content model with +The following uncategorized improvements have been made: + + * Added limited support for complexType complexContent content model with restriction variety. SOAP::WSDL now supports this XML Schema definition variant, although no constraints are imposed on derived types yet. - Derived types do not serialize with a xsi:type attribute (and the xsi:type - attribute is not recognized by the XML parser), so you cannot use derived + Derived types do not serialize with a xsi:type attribute (and the xsi:type + attribute is not recognized by the XML parser), so you cannot use derived types as a substitute for theri parent, yet. * Added support for complexType choice variety complexType definitions using the choice variety are now supported, - even though the content is not checked (if you pass in invalid data, + even though the content is not checked (if you pass in invalid data, invalid XML will be generated). * Added Loopback Transport backend. - SOAP::WSDL::Tranport::Loopback just returns the request as respons, but + SOAP::WSDL::Tranport::Loopback just returns the request as respons, but allows testing the whole chain from user interface to transport backend. - * Fixed SOAP::WSDL::Factory::Transport prefer user-registered + * Fixed SOAP::WSDL::Factory::Transport prefer user-registered transport backend * Fixed set_soap_version method in SOAP::WSDL::Client. - Re-setting the SOAP version now invalidates (resets) serializer and + Re-setting the SOAP version now invalidates (resets) serializer and deserializer, but not the transport backend. - * Fixed SOAP::WSDL::XSD::Typelib::Builtin::boolean to return false + * Fixed SOAP::WSDL::XSD::Typelib::Builtin::boolean to return false when false and true when true. - * SOAP::WSDL::XSD::Typelib::Builtin::normalizedString now replaces all + * SOAP::WSDL::XSD::Typelib::Builtin::normalizedString now replaces all occurences of tab, newline and carriage return by whitespce on set_value. * Code cleanup - o Lots of orphan methods now replaced by the SOAP::WSDL::Generator + o Lots of orphan methods now replaced by the SOAP::WSDL::Generator hierarchy have been removed. - o Unused (and unusable) readable option checking has been removed in + o Unused (and unusable) readable option checking has been removed in SOAP::WSDL::Serializer::SOAP11. - o Unused XML Schema facet attributes have been removed from XSD Builtin + o Unused XML Schema facet attributes have been removed from XSD Builtin classes - o Methods common to all expat parser classes have been factored out + o Methods common to all expat parser classes have been factored out into a common base class. - + * XML serialization speedup for SOAP::WSDL::XSD::* objects * Tests added to improve test coverage. @@ -342,7 +384,7 @@ The following uncategorized improvements have been made: 2.00_16 ---- -The following features were added (the numbers in square brackets are the +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): * [ 1761532 ] Support embedded atomic types @@ -358,11 +400,11 @@ tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): * [ 1803330 ] Create one interface per port SOAP::WSDL now creates one interface per port, not one per service. -The following bugs have been fixed (the numbers in square brackets are the +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): * [ 1804441 ] parts from binding not regarded in SOAP::WSDL - SOAP::WSDL (interpreter mode) now respects the body parts specified in the + SOAP::WSDL (interpreter mode) now respects the body parts specified in the binding. * [ 1803763 ] nonNegativeInteger misspelled in Schema::Builtin @@ -370,35 +412,35 @@ tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660921): * [ 1793965 ] _expand() does not work on non-root-node ns declarations * [ 1792348 ] 006_client.t requires SOAP::Lite in 2.00_15 - SOAP::WSDL no longer attempts to load SOAP::WSDL::Deserializer::SOM when + SOAP::WSDL no longer attempts to load SOAP::WSDL::Deserializer::SOM when no_dispatch is set. 006_client.t now sets outputxml(1), to be really sure. - -The following uncategorized improvements have been made: + +The following uncategorized improvements have been made: * Code generator only generates interface for the first port in a service The code generator now generates interfaces for all ports. Note: The naming scheme has changed. It is now InterfacePrefix::Service::Port - + * XML Parser speedup The XML parser has received a little speedup. - - * A number of errors in parsing / traversing WSDL documents have been + + * A number of errors in parsing / traversing WSDL documents have been corrected. - + * Documentation has been improved - + * A number of (incorrect, but passing) tests have been fixed. - * Code cleanup: The SOAP::WSDL::SAX* modules are no longer included, as they - are not supported any more. They can still be found in SOAP::WSDL's + * Code cleanup: The SOAP::WSDL::SAX* modules are no longer included, as they + are not supported any more. They can still be found in SOAP::WSDL's subversion repository in the attic directory, though. - + 2.00_15 ---- -The following bugs have been fixed (the numbers in square brackets are the +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): * [ 1792321 ] 2.00_14 requires SOAP::Lite for passing tests @@ -406,7 +448,7 @@ tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660921): 2.00_14 ---- -The following bugs have been fixed (the numbers in square brackets are the +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): * [ 1792235 ] SOAP::WSDL::Transport::Test missing from 2.00_13 @@ -417,7 +459,7 @@ tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660921): The following uncategorized improvements have been made: - * The ::SOM deserializer has been simplified to be just a subclass + * The ::SOM deserializer has been simplified to be just a subclass of SOAP::Deserializer from SOAP::Lite * Factories now emit more useful error messages when no class is registered for the protocol/soap_version requested @@ -428,36 +470,36 @@ The following uncategorized improvements have been made: 2.00_13 ---- -The following features were added (the numbers in square brackets are the +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): * [ 1790619 ] Test transport backend A test transport backend has been implemented (SOAP::WSDL::Transport::Test). It returns the contents from a file and discards the response. The filename is determined from the soap_action field. - + * [ 1785196 ] Replace outputsom(1) by deserializer plugin - outputsom(1) in SOAP::WSDL is now implemented via using the deserializer + outputsom(1) in SOAP::WSDL is now implemented via using the deserializer plugin SOAP::WSDL::Deserializer::SOM. * [1785195] Support deserializer plugins Deserializer plugin API added via SOAP::WSDL::Factory::Deserializer. - -The following bugs have been fixed (the numbers in square brackets are the + +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): * [1789581] Support ComplexType mixed - WSDL parser now supports using the mixed="true" attribute in complexType + WSDL parser now supports using the mixed="true" attribute in complexType definitions. Mixed content in messages is only supported via SOAP::SOM yet. * [1787975] 016_client_object.t fails due to testing XML as string Removed string test. - + * [1787959] Test wsdl seems to be broken Corrected typo. - + * [1787955] ::XSD::Typelib::date is broken - SOAP::WSDL::XSD::Typelib::Builtin::date now converts time-zoned dates properly, + SOAP::WSDL::XSD::Typelib::Builtin::date now converts time-zoned dates properly, and adds the local time zone if none is given. * [1785646] SOAPAction header not set from soap:operation soapAction @@ -469,55 +511,55 @@ The following uncategorized improvements have been made: 2.00_12 ---- - -The following bugs have been fixed (the numbers in square brackets are the + +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): * [1787146] SOAP::WSDL still uses XML::LibXML - The superficious usage of XML::LibXML has been removed. XML::LibXML with + The superficious usage of XML::LibXML has been removed. XML::LibXML with sax filter has been replaced by SOAP::WSDL::Expat::WSDLParser. - + * [1787054] Test suite requires XML::LibXML in 2.00_11 The test suite no longer requires XML::LibXML to pass. * [1785678] SOAP envelope not checked for namespace The SOAP envelope is now checked for the correct namespace. - + * [1786644] SOAP::WSDL::Manual - doc error Documentation improvements - + The following uncategorized improvements have been made * The SOAPAction header is now alway quoted (R1109 in WS-I BP 1.0). - + 2.00_11 ---- -The following features were added (the numbers in square brackets are the +The following features were added (the numbers in square brackets are the tracker IDs from https://sourceforge.net/tracker/?group_id=111978&atid=660924): * [1767963] Transport plugins via SOAP::WSDL::Factory::Transport. - SOAP::WSDL uses SOAP::Lite's tranport modules as default, with a + SOAP::WSDL uses SOAP::Lite's tranport modules as default, with a lightweight HTTP(S) transport plugin as fallback. Custom transport modules can be registered via SOAP::WSDL::Factory::Transport. - * [ 1772730 ] Serializer plugins via SOAP::WSDL::Factory::Serializer + * [ 1772730 ] Serializer plugins via SOAP::WSDL::Factory::Serializer The default serializer for SOAP1.1 is SOAP::WSDL::Serializer::SOAP11. - Custom serializers classes can be registered via - SOAP::WSDL::Factory::Serializer or set via SOAP::WSDL's set_serializer + Custom serializers classes can be registered via + SOAP::WSDL::Factory::Serializer or set via SOAP::WSDL's set_serializer method. -The following bugs have been fixed (the numbers in square brackets are the +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): * [ 1764854 ] Port WSDL parser to expat and remove XML::LibXML dependency SOAP::WSDL now requires only XML::Parser to be installed. - XML::LibXML is not required any more, though XML::LibXML based modules still + XML::LibXML is not required any more, though XML::LibXML based modules still exist. The following uncategorized improvements have been made - * The number of dependencies has been reduced. SOAP::WSDL no longer requires the + * The number of dependencies has been reduced. SOAP::WSDL no longer requires the following modules to be installed: - XML::SAX::Base - XML::SAX::ParserFactory @@ -536,27 +578,27 @@ The following uncategorized improvements have been made 2.00_09 ---- - * SOAP::WSDL::XSD::Typelib::Builtin::boolean objects now return their numerical + * SOAP::WSDL::XSD::Typelib::Builtin::boolean objects now return their numerical value in bool context, not "true" or "false" (always true...) * date/time test are now timezone-sensitive * examples added 2.00_08 --- - * SOAP::WSDL::XSD::Typelib::ComplexType objects now check the class of their + * SOAP::WSDL::XSD::Typelib::ComplexType objects now check the class of their child objects. This provides early feedback to developers. - * SOAP message parser can skip unwanted parts of the message to improve parsing + * SOAP message parser can skip unwanted parts of the message to improve parsing speed - see SOAP::WSDL::Expat::MessageParser for details. * HTTP Content-Type is configurable - * SOAP::WSDL::XSD::Typelib::ComplexType based objects accept any combination of + * SOAP::WSDL::XSD::Typelib::ComplexType based objects accept any combination of hash refs, list refs and objects as parameter to set_value() and new(). - * SOAP::WSDL::XSD::Typelib::Builtin::dateTime and ::date convert date + * SOAP::WSDL::XSD::Typelib::Builtin::dateTime and ::date convert date strings into XML date strings * SOAP::WSDL::Definitions::create now - - converts '.' in service names to '::' (.NET class separator to perl class + - converts '.' in service names to '::' (.NET class separator to perl class separator) - - outputs Typemaps and Interface classes in UTF8 to allow proper inclusion + - outputs Typemaps and Interface classes in UTF8 to allow proper inclusion of UTF8 documentation from WSDL * SOAP::WSDL::Definitions::create() includes doc in generated interface classes * WSDLHandler now handles tags @@ -567,7 +609,7 @@ The following uncategorized improvements have been made * Implemented a Code generator for creating SOAP interfaces based on WSDL definitions * Implemented a high-speed stream based SOAP message parser SOAP message parser returns a objects based on XML schema based class library - * Implemented a XML schema based class library + * Implemented a XML schema based class library * Implemented a stream based WSDL parser. - Parses WSDL into objects. Objects can serialize data, and explain how to use the + Parses WSDL into objects. Objects can serialize data, and explain how to use the service(s) they make up (output documentation). diff --git a/MANIFEST b/MANIFEST index 9fa3564..73f4881 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2,6 +2,7 @@ benchmark/01_expat.t benchmark/hello.pl benchmark/person.pl benchmark/person.xml +benchmark/person_profile.pl benchmark/XSD/01_anyType.t benchmark/XSD/02_anySimpleType.t benchmark/XSD/03_string.t @@ -229,7 +230,6 @@ Makefile.PL MANIFEST This list of files META.yml MIGRATING -patches/Manual.diff README t/001_use.t t/002_parse_wsdl.t @@ -281,7 +281,10 @@ t/acceptance/wsdl/email_account.wsdl t/acceptance/wsdl/generator_test.wsdl t/acceptance/wsdl/generator_test_dot_names.wsdl t/acceptance/wsdl/generator_unsupported_test.wsdl +t/acceptance/wsdl/import.xsd t/acceptance/wsdl/message_gateway.wsdl +t/acceptance/wsdl/WSDLParser-import.wsdl +t/acceptance/wsdl/WSDLParser-imported.wsdl t/acceptance/wsdl/WSDLParser.wsdl t/contributed.wsdl t/Expat/03_wsdl.t @@ -313,6 +316,7 @@ t/SOAP/WSDL/11_helloworld.NET.t t/SOAP/WSDL/12_binding.t t/SOAP/WSDL/Client.t t/SOAP/WSDL/Client/Base.t +t/SOAP/WSDL/Definitions.t t/SOAP/WSDL/Deserializer/Hash.t t/SOAP/WSDL/Deserializer/SOM.t t/SOAP/WSDL/Deserializer/XSD.t @@ -330,6 +334,7 @@ t/SOAP/WSDL/Generator/XSD.t t/SOAP/WSDL/Generator/XSD_dot_names.t t/SOAP/WSDL/Generator/XSD_unsupported.t t/SOAP/WSDL/Part.t +t/SOAP/WSDL/PortType.t t/SOAP/WSDL/Serializer/XSD.t t/SOAP/WSDL/Server.t t/SOAP/WSDL/Server/CGI.t @@ -338,8 +343,10 @@ t/SOAP/WSDL/Transport/02_HTTP.t t/SOAP/WSDL/Transport/acceptance/test2.xml t/SOAP/WSDL/Transport/acceptance/test3.xml t/SOAP/WSDL/Typelib/Fault11.t +t/SOAP/WSDL/XSD/Attribute.t t/SOAP/WSDL/XSD/ComplexType.t t/SOAP/WSDL/XSD/Element.t +t/SOAP/WSDL/XSD/Schema.t t/SOAP/WSDL/XSD/SimpleType.t t/SOAP/WSDL/XSD/Typelib/Attribute.t t/SOAP/WSDL/XSD/Typelib/Builtin/01_constructors.t diff --git a/META.yml b/META.yml index f06e077..6b5b422 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- name: SOAP-WSDL -version: 2.00_29 +version: 2.00_31 author: - 'Martin Kutter ' abstract: SOAP with WSDL support @@ -25,12 +25,13 @@ requires: List::Util: 0 Template: 0 Term::ReadKey: 0 + URI: 0 XML::Parser::Expat: 0 perl: 5.8.0 provides: SOAP::WSDL: file: lib/SOAP/WSDL.pm - version: 2.00_25 + version: 2.00_31 SOAP::WSDL::Base: file: lib/SOAP/WSDL/Base.pm version: 2.00_27 @@ -77,7 +78,7 @@ provides: version: 2.00_24 SOAP::WSDL::Factory::Transport: file: lib/SOAP/WSDL/Factory/Transport.pm - version: 2.00_25 + version: 2.00_31 SOAP::WSDL::Generator::Template: file: lib/SOAP/WSDL/Generator/Template.pm version: 2.00_25 @@ -139,7 +140,7 @@ provides: version: 2.00_25 SOAP::WSDL::TypeLookup: file: lib/SOAP/WSDL/TypeLookup.pm - version: 2.00_29 + version: 2.00_31 SOAP::WSDL::Types: file: lib/SOAP/WSDL/Types.pm SOAP::WSDL::XSD::Attribute: @@ -149,7 +150,7 @@ provides: file: lib/SOAP/WSDL/XSD/Builtin.pm SOAP::WSDL::XSD::ComplexType: file: lib/SOAP/WSDL/XSD/ComplexType.pm - version: 2.00_25 + version: 2.00_29 SOAP::WSDL::XSD::Element: file: lib/SOAP/WSDL/XSD/Element.pm version: 2.00_25 @@ -163,8 +164,10 @@ provides: version: 2.00_25 SOAP::WSDL::XSD::Typelib::Attribute: file: lib/SOAP/WSDL/XSD/Typelib/Attribute.pm + version: 2.00_29 SOAP::WSDL::XSD::Typelib::AttributeSet: file: lib/SOAP/WSDL/XSD/Typelib/AttributeSet.pm + version: 2.00_29 SOAP::WSDL::XSD::Typelib::Builtin: file: lib/SOAP/WSDL/XSD/Typelib/Builtin.pm version: 2.00_25 @@ -265,7 +268,7 @@ provides: file: lib/SOAP/WSDL/XSD/Typelib/Builtin/unsignedShort.pm SOAP::WSDL::XSD::Typelib::ComplexType: file: lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm - version: 2.00_29 + version: 2.00_31 SOAP::WSDL::XSD::Typelib::Element: file: lib/SOAP/WSDL/XSD/Typelib/Element.pm version: 2.00_29 diff --git a/MIGRATING b/MIGRATING index 5b0095c..13fb2ad 100644 --- a/MIGRATING +++ b/MIGRATING @@ -1,7 +1,23 @@ MIGRATING --------- -This document describes how to migrate from 2.00_24 and before versions to +MIGRATING FROM PRE-2.00_29 +-------------------------- +SOAP::WSDL 2.00_29 added experimental XML attribute support. The attribute +support changed the code of the generated classes, which may now +require the class SOAP::WSDL::XSD::Typelib::Attribute introduced in the same +pre-release. + +While interfaces generated with pre-releases back to 2.00_25 work without +change, this does not hold true vice versa: Interfaces generated with +2.00_29 and above won't work with older pre-releases. + +You'll have to update SOAP::WSDL on all your machines. + +MIGRATING FROM PRE-2.00_24 +-------------------------- + +This section describes how to migrate from 2.00_24 and before versions to 2.00_25. Migrating from 2.00_xx diff --git a/benchmark/person_profile.pl b/benchmark/person_profile.pl new file mode 100644 index 0000000..db35420 --- /dev/null +++ b/benchmark/person_profile.pl @@ -0,0 +1,11 @@ +use lib '../lib'; +use lib '../example/lib'; +use lib '../../SOAP-WSDL_XS/blib/lib'; +use lib '../../SOAP-WSDL_XS/blib/arch'; +use strict; + +use MyInterfaces::TestService::TestPort; + +my $soap = MyInterfaces::TestService::TestPort->new(); +# Load all classes - XML::Compile has created everything before, too +for (1..100) { $soap->ListPerson({}) }; diff --git a/bin/wsdl2perl.pl b/bin/wsdl2perl.pl index a642a06..1369096 100644 --- a/bin/wsdl2perl.pl +++ b/bin/wsdl2perl.pl @@ -23,10 +23,10 @@ my %opt = ( { # a block just to scope "no warnings" no warnings qw(redefine); - + *LWP::UserAgent::get_basic_credentials = sub { my ($user, $password); - # remove user from option if called, to force prompting for a user + # remove user from option if called, to force prompting for a user # name the next time print "URL requires authorization.\n"; if (not $user = delete $opt{user}) { @@ -39,14 +39,14 @@ my %opt = ( print 'Password:'; ReadMode 2; $user = ReadLine; - ReadMode 0; + ReadMode 0; }; return ($user, $password); - }; + }; } GetOptions(\%opt, - qw( + qw( prefix|p=s type_prefix|t=s element_prefix|e=s @@ -69,24 +69,21 @@ my $url = $ARGV[0]; pod2usage( -exit => 1 , verbose => 2 ) if ($opt{help}); pod2usage( -exit => 1 , verbose => 1 ) if not ($url); -my $parser = SOAP::WSDL::Expat::WSDLParser->new(); - local $ENV{HTTP_PROXY} = $opt{proxy} if $opt{proxy}; local $ENV{HTTPS_PROXY} = $opt{proxy} if $opt{proxy}; -my $lwp = LWP::UserAgent->new( - $opt{keep_alive} - ? ( keep_alive => 1 ) +my $lwp = LWP::UserAgent->new( + $opt{keep_alive} + ? ( keep_alive => 1 ) : () ); $lwp->env_proxy(); # get proxy from environment. Works for both http & https. -my $response = $lwp->get($url); -die $response->message(), "\n" if $response->code != 200; +my $parser = SOAP::WSDL::Expat::WSDLParser->new({ + user_agent => $lwp, +}); -my $xml = $response->content(); - -my $definitions = $parser->parse_string( $xml ); +my $definitions = $parser->parse_uri( $url ); my %typemap = (); @@ -112,7 +109,7 @@ $generator->set_element_prefix($opt{ element_prefix }) if $generator->can('set_e $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'); +# $generator->set_wsdl($xml) if $generator->can('set_wsdl'); # start with typelib, as errors will most likely occur here... $generator->generate(); @@ -136,33 +133,33 @@ wsdl2perl.pl - create perl bindings for SOAP webservices. NAME SHORT DESCRITPION ---------------------------------------------------------------------------- prefix p Prefix for both type and element classes. - type_prefix t Prefix for type classes. + type_prefix t Prefix for type classes. Default: MyTypes - element_prefix e Prefix for element classes. + element_prefix e Prefix for element classes. Default: MyElements - typemap_prefix m Prefix for typemap classes. + typemap_prefix m Prefix for typemap classes. Default: MyTypemaps interface_prefix i Prefix for interface classes. Default: MyInterfaces base_path b Path to create classes in. Default: . - typemap_include mi File to include in typemap. Must eval() to a valid + typemap_include mi File to include in typemap. Must eval() to a valid perl hash (not a hash ref !). - proxy x HTTP(S) proxy to use (if any). wsdl2perl will also + 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 + generator g Generator to use. + Default: XSD server s Generate a server interface (currently only CGI supported) help h Show help content =head1 DESCRIPTION -Generates a interface class for a SOAP web service described by a WSDL +Generates a interface class for a SOAP web service described by a WSDL definition. The following classes are created: @@ -171,7 +168,7 @@ The following classes are created: =item * A interface class for every SOAP port in service -Interface classes are what you will mainly deal with: They provide a method +Interface classes are what you will mainly deal with: They provide a method for accessing every web service method. If you chose to generate Server interfaces, a class for every SOAP port in @@ -183,13 +180,13 @@ to dispatch calls to. =item * A typemap for every service -Typemaps are used internally by SOAP::WSDL for parsing the SOAP message into -object trees. +Typemaps are used internally by SOAP::WSDL for parsing the SOAP message into +object trees. -If the WSDL definition is incomplete, you may need to add some lines to +If the WSDL definition is incomplete, you may need to add some lines to your typemap. Especially definitions for faults are sometimes left out. -Additional typemap content may be included by passing a file name as +Additional typemap content may be included by passing a file name as typemap_include (mi) option. =item * A type class for every element, complexType or simpleType definition @@ -197,7 +194,7 @@ typemap_include (mi) option. You may need to write additional type classes if your WSDL is incomplete. For writing your own lib classes, see L, -L +L and L. =back @@ -210,26 +207,26 @@ You need Crypt::SSLeay installed for accessing HTTPS URLs. =head2 Accessing protected documents -Use the -u option for specifying the user name. You will be prompted for a -password. +Use the -u option for specifying the user name. You will be prompted for a +password. -Alternatively, you may specify a passowrd with --password on the command +Alternatively, you may specify a passowrd with --password on the command line. =head2 Accessing documents protected by NTLM authentication Set the --keep_alive option. -Note that accessing documents protected by NTLM authentication is currently +Note that accessing documents protected by NTLM authentication is currently untested, because I have no access to a system using NTLM authentication. -If you try it, I would be glad if you could just drop me a note about -success or failure. +If you try it, I would be glad if you could just drop me a note about +success or failure. =head1 LICENSE Copyright 2007 Martin Kutter. -This file is part of SOAP-WSDL. You may distribute/modify it under +This file is part of SOAP-WSDL. You may distribute/modify it under the same terms as perl itself =head1 AUTHOR diff --git a/lib/SOAP/WSDL.pm b/lib/SOAP/WSDL.pm index 5a53dfa..1967f83 100644 --- a/lib/SOAP/WSDL.pm +++ b/lib/SOAP/WSDL.pm @@ -14,7 +14,7 @@ use Class::Std::Fast; use SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType; use LWP::UserAgent; -our $VERSION= '2.00_25'; +our $VERSION= '2.00_31'; my %no_dispatch_of :ATTR(:name); my %wsdl_of :ATTR(:name); @@ -176,7 +176,7 @@ sub _wsdl_init_methods :PRIVATE { my $ns = $wsdl->get_targetNamespace(); # get bindings, portType, message, part(s) - use private methods for clear separation... - $self->_wsdl_get_service if not ($service_of{ $ident }); + $self->_wsdl_get_service(); $self->_wsdl_get_portType(); $method_info_of{ $ident } = {}; @@ -187,9 +187,10 @@ sub _wsdl_init_methods :PRIVATE { # get SOAP Action # SOAP-Action is a required HTTP Header, so we need to look it up... + # There must be a soapAction uri - or the WSDL is invalid (and + # it's not us to prove that...) my $soap_binding_operation = $binding_operation->get_operation()->[0]; - $method->{ soap_action } = $soap_binding_operation ? - $soap_binding_operation->get_soapAction() : $method; + $method->{ soap_action } = $soap_binding_operation->get_soapAction(); # get parts # 1. get operation from port @@ -204,7 +205,10 @@ sub _wsdl_init_methods :PRIVATE { my $message = $wsdl->find_message( $ns, $localname ) or croak "Message {$ns}$localname not found in WSDL definition"; - if (my $body=$binding_operation->first_input()->first_body()) { + # Is body not required? So there must be one? Do we need the "if"? + # if ( + my $body=$binding_operation->first_input()->first_body(); + # { if ($body->get_parts()) { $method->{ parts } = []; # make sure it's empty my $message_part_ref = $message->get_part(); @@ -216,7 +220,9 @@ sub _wsdl_init_methods :PRIVATE { grep { $_->get_name() eq $name } @{ $message_part_ref }; } } - } + # } + # A body does not need to specify the parts of a messages. + # Use all of the message's parts if it does not. $method->{ parts } ||= $message->get_part(); # rpc / encoded methods may have a namespace specified. @@ -329,7 +335,7 @@ SOAP client, which mimics L's API, read on. my $soap = SOAP::WSDL->new( wsdl => 'file://bla.wsdl', ); - + my $result = $soap->call('MyMethod', %data); =head1 DESCRIPTION @@ -436,7 +442,7 @@ Class resolver 'Person/Name' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Person/FirstName' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', ); - + sub get_class { return $typemap{ $_[1] } }; 1; @@ -730,9 +736,9 @@ Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION - $Rev: 477 $ + $Rev: 524 $ $LastChangedBy: kutterma $ - $Id: WSDL.pm 477 2007-12-24 10:23:52Z kutterma $ + $Id: WSDL.pm 524 2008-02-10 23:24:43Z kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL.pm $ =cut diff --git a/lib/SOAP/WSDL/Client/Base.pm b/lib/SOAP/WSDL/Client/Base.pm index 777faab..ccf31e0 100644 --- a/lib/SOAP/WSDL/Client/Base.pm +++ b/lib/SOAP/WSDL/Client/Base.pm @@ -8,22 +8,32 @@ our $VERSION = '2.00_25'; sub call { my ($self, $method, $body, $header) = @_; + + # Treat non-objects special if (not blessed $body) { + + # make sure there's something sensible in our body data $body = {} if not defined $body; $body = ref $body eq 'ARRAY' ? $body : [ $body ]; - my $index = 0; - my @part_from; - foreach my $part (@{ $body }) { - my $class = $method->{ body }->{ parts }->[$index]; + + my @body_from = @{ $body }; # make a copy + + # build list of parts as objects initialized with + # parameters given + my @part_from = (); + foreach my $class (@{ $method->{ body }->{ parts } }) { eval "require $class" || die $@; - push @part_from, $class->new($part); - $index++; + push @part_from, $class->new(shift(@body_from) || {}); } + + # it's either the first part or a list ref with all parts... $body = $#part_from ? \@part_from : $part_from[0]; } # if we have a header if (%{ $method->{ header } }) { + + # trat non object special - as above, but only for one if (not blessed $header) { my $class = $method->{ header }->{ parts }->[0]; eval "require $class" || die $@; @@ -33,39 +43,6 @@ sub call { return $self->SUPER::call($method, $body, $header); } -#sub __create_methods { -# my ($package, %info_of) = @_; -# -# no strict qw(refs); -# no warnings qw(redefine); -# for my $method (keys %info_of){ -# my ($soap_action, @parts); -# -# # up to 2.00_10 we had list refs... -# if (ref $info_of{ $method }eq 'HASH') { -# @parts = @{ $info_of{ $method }->{ parts } }; -# $soap_action = $info_of{ $method }->{ soap_action }; -# } -# else { -# die "Pre-v2.00_10 Interfaces are no longer supported. Please re-generate your interface."; -# } -# -# *{ "$package\::$method" } = sub { -# my $self = shift; -# my @param = map { -# my $data = shift || {}; -# eval "require $_"; -# $_->new( $data ); -# } @parts; -# -# return $self->SUPER::call( { -# operation => $method, -# soap_action => $soap_action, -# }, @param ); -# } -# } -#} - 1; __END__ @@ -101,9 +78,9 @@ Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION - $Rev: 440 $ + $Rev: 501 $ $LastChangedBy: kutterma $ - $Id: Base.pm 440 2007-12-04 22:24:33Z kutterma $ + $Id: Base.pm 501 2008-01-26 20:23:32Z kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Client/Base.pm $ =cut diff --git a/lib/SOAP/WSDL/Deserializer/XSD.pm b/lib/SOAP/WSDL/Deserializer/XSD.pm index 9d2e1b7..ed28967 100644 --- a/lib/SOAP/WSDL/Deserializer/XSD.pm +++ b/lib/SOAP/WSDL/Deserializer/XSD.pm @@ -23,7 +23,8 @@ sub BUILD { sub deserialize { my ($self, $content) = @_; - $parser_of{ ${ $self } } ||= SOAP::WSDL::Expat::MessageParser->new(); + $parser_of{ ${ $self } } = SOAP::WSDL::Expat::MessageParser->new() + if not $parser_of{ ${ $self } }; $parser_of{ ${ $self } }->class_resolver( $class_resolver_of{ ident $self } ); eval { $parser_of{ ${ $self } }->parse_string( $content ) }; if ($@) { @@ -98,9 +99,9 @@ Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION - $Rev: 427 $ + $Rev: 501 $ $LastChangedBy: kutterma $ - $Id: XSD.pm 427 2007-12-02 22:20:24Z kutterma $ + $Id: XSD.pm 501 2008-01-26 20:23:32Z kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Deserializer/XSD.pm $ =cut diff --git a/lib/SOAP/WSDL/Expat/Base.pm b/lib/SOAP/WSDL/Expat/Base.pm index e5b2894..9c956a8 100644 --- a/lib/SOAP/WSDL/Expat/Base.pm +++ b/lib/SOAP/WSDL/Expat/Base.pm @@ -1,17 +1,47 @@ package SOAP::WSDL::Expat::Base; use strict; use warnings; +use URI; use XML::Parser::Expat; +# TODO: convert to Class::Std::Fast based class - hash based classes suck. + our $VERSION = '2.00_27'; sub new { - my ($class, $args) = @_; + my ($class, $arg_ref) = @_; my $self = {}; bless $self, $class; + + $self->set_user_agent($arg_ref->{ user_agent }) + if $arg_ref->{ user_agent }; + return $self; } +sub set_uri { $_[0]->{ uri } = $_[1]; } +sub get_uri { return $_[0]->{ uri }; } + +sub set_user_agent { $_[0]->{ user_agent } = $_[1]; } +sub get_user_agent { return $_[0]->{ user_agent }; } + + +sub parse_uri { + my $self = shift; + my $uri = shift; + $self->set_uri( $uri ); + + if (not $self->{ user_agent }) { + require LWP::UserAgent; + $self->{ user_agent } = LWP::UserAgent->new(); + } + + my $response = $self->{ user_agent }->get($uri); + + die $response->message() if $response->code() ne '200'; + return $self->parse( $response->content() ); +} + sub parse { eval { $_[0]->_initialize( XML::Parser::Expat->new( Namespaces => 1 ) )->parse( $_[1] ); diff --git a/lib/SOAP/WSDL/Expat/MessageParser.pm b/lib/SOAP/WSDL/Expat/MessageParser.pm index 681c8c2..c482d4e 100644 --- a/lib/SOAP/WSDL/Expat/MessageParser.pm +++ b/lib/SOAP/WSDL/Expat/MessageParser.pm @@ -128,7 +128,7 @@ sub _initialize { return &{$content_check{ $depth }} if exists $content_check{ $depth }; - push @{ $path }, $_[1]; # step down in path + push @{ $path }, $_[1]; # step down in path return if $skip; # skip inside __SKIP__ # resolve class of this element @@ -171,6 +171,7 @@ sub _initialize { $current = bless \$o, $_class; } + # set attributes if there are any $current->attr({ @_[2..$#_] }) if (@_ > 2); $depth++; @@ -294,8 +295,8 @@ the same terms as perl itself $Id: $ - $LastChangedDate: 2008-01-19 13:57:57 +0100 (Sa, 19 Jan 2008) $ - $LastChangedRevision: 497 $ + $LastChangedDate: 2008-02-02 10:19:45 +0100 (Sa, 02 Feb 2008) $ + $LastChangedRevision: 516 $ $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/WSDLParser.pm b/lib/SOAP/WSDL/Expat/WSDLParser.pm index 8b3c72a..2eef7ed 100644 --- a/lib/SOAP/WSDL/Expat/WSDLParser.pm +++ b/lib/SOAP/WSDL/Expat/WSDLParser.pm @@ -5,7 +5,57 @@ use Carp; use SOAP::WSDL::TypeLookup; use base qw(SOAP::WSDL::Expat::Base); -our $VERSION = q{2.00_29}; +our $VERSION = q{2.00_31}; + +sub _import_children { + my ($self, $name, $imported, $importer, $import_namespace) = @_; + my $targetNamespace = $importer->get_targetNamespace(); + my $push_method = "push_$name"; + my $get_method = "get_$name"; + no strict qw(refs); + my $value_ref = $imported->$get_method(); + if ($value_ref) { + $value_ref = [ $value_ref ] if (not ref $value_ref eq 'ARRAY'); + # set xmlns - can be different from parent + for (@{ $value_ref }) { + # fixup targetNamespace, but don't override + $_->set_targetNamespace( $import_namespace ) + if ( ($import_namespace ne $targetNamespace) && ! $_->get_targetNamespace); + # update parent... + $_->set_parent( $importer ); + } + # push elements into importing WSDL + $importer->$push_method(@{ $value_ref }); + } +} + +sub xml_schema_import { + my $self = shift; + my $schema = shift; + my $parser = ref($self)->new(); + my %attr_of = @_; + my $import_namespace = $attr_of{ namespace }; + my $uri = URI->new_abs($attr_of{schemaLocation}, $self->get_uri() ); + my $import = $parser->parse_uri($uri); + + for my $name ( qw(type element group) ) { + $self->_import_children( $name, $import, $schema, $import_namespace); + } +} + +sub wsdl_import { + my $self = shift; + my $definitions = shift; + my $parser = ref($self)->new(); + my %attr_of = @_; + my $import_namespace = $attr_of{ namespace }; + my $uri = URI->new_abs($attr_of{location}, $self->get_uri() ); + + my $import = $parser->parse_uri($uri); + for my $name ( qw(types message binding portType service) ) { + $self->_import_children( $name, $import, $definitions, $import_namespace); + } +} sub _initialize { my ($self, $parser) = @_; @@ -81,6 +131,20 @@ sub _initialize { : _fixup_attrs($parser, %attrs) ); } + elsif ($action->{type} eq 'HANDLER') { + my $method = $self->can($action->{method}); + $method->($self, $current, %attrs); + } + else { + # TODO replace by hash lookup of known namespaces. + my $namespace = $parser->namespace($localname) || q{}; + my $part = $namespace eq 'http://schemas.xmlsoap.org/wsdl/' + ? 'WSDL 1.1' + : 'XML Schema'; + + warn "$part element <$localname> is not implemented yet" + if ($localname !~m{ \A (:? annotation | documentation ) \z }xms ); + } return; }, @@ -179,8 +243,8 @@ the same terms as perl itself $Id: $ - $LastChangedDate: 2007-12-24 11:23:52 +0100 (Mo, 24 Dez 2007) $ - $LastChangedRevision: 477 $ + $LastChangedDate: 2008-02-11 00:14:27 +0100 (Mo, 11 Feb 2008) $ + $LastChangedRevision: 522 $ $LastChangedBy: kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/WSDLParser.pm $ diff --git a/lib/SOAP/WSDL/Factory/Deserializer.pm b/lib/SOAP/WSDL/Factory/Deserializer.pm index 6774745..f8956e1 100644 --- a/lib/SOAP/WSDL/Factory/Deserializer.pm +++ b/lib/SOAP/WSDL/Factory/Deserializer.pm @@ -16,7 +16,7 @@ sub register { sub get_deserializer { my ($self, $args_of_ref) = @_; - + $args_of_ref->{ soap_version } ||= '1.1'; # sanity check die "no deserializer registered for SOAP version $args_of_ref->{ soap_version }" if not exists ($DESERIALIZER{ $args_of_ref->{ soap_version } }); diff --git a/lib/SOAP/WSDL/Factory/Serializer.pm b/lib/SOAP/WSDL/Factory/Serializer.pm index 82c7a2a..5d675a3 100644 --- a/lib/SOAP/WSDL/Factory/Serializer.pm +++ b/lib/SOAP/WSDL/Factory/Serializer.pm @@ -16,7 +16,7 @@ sub register { sub get_serializer { my ($self, $args_of_ref) = @_; - + $args_of_ref->{ soap_version } ||= '1.1'; # sanity check die "no serializer registered for SOAP version $args_of_ref->{ soap_version }" if not exists ($SERIALIZER{ $args_of_ref->{ soap_version } }); @@ -138,9 +138,9 @@ Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION - $Rev: 391 $ + $Rev: 510 $ $LastChangedBy: kutterma $ - $Id: Serializer.pm 391 2007-11-17 21:56:13Z kutterma $ + $Id: Serializer.pm 510 2008-01-29 08:03:46Z kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Factory/Serializer.pm $ =cut diff --git a/lib/SOAP/WSDL/Factory/Transport.pm b/lib/SOAP/WSDL/Factory/Transport.pm index b13a3fa..176a235 100644 --- a/lib/SOAP/WSDL/Factory/Transport.pm +++ b/lib/SOAP/WSDL/Factory/Transport.pm @@ -2,7 +2,7 @@ package SOAP::WSDL::Factory::Transport; use strict; use warnings; -our $VERSION='2.00_25'; +our $VERSION='2.00_31'; # class data my %registered_transport_of = (); @@ -34,7 +34,7 @@ sub register { sub get_transport { my ($class, $scheme, %attrs) = @_; - $scheme =~s{ \A ([^\:]+) \: .+ }{$1}smx; + $scheme =~s{ \A ([^\:]+) \: .+ }{$1}x; if ($registered_transport_of{ $scheme }) { no strict qw(refs); @@ -96,12 +96,12 @@ SOAP::WSDL::Factory::Transport - Factory for retrieving transport objects # in transport class: package MyWickedTransport; use SOAP::WSDL::Factory::Transport; - + # register class as transport module for httpr and https # (httpr is "reliable http", a protocol developed by IBM). SOAP::WSDL::Factory::Transport->register( 'httpr' , __PACKAGE__ ); SOAP::WSDL::Factory::Transport->register( 'https' , __PACKAGE__ ); - + =head1 DESCRIPTION SOAP::WSDL::Transport serves as factory for retrieving transport objects for @@ -207,10 +207,10 @@ classes in one file, and to follow this naming scheme: Module name: "SOAP::Transport::" . uc($scheme) - + Client class (additional package in module): "SOAP::Transport::" . uc($scheme) . "::Client" - + Server class (additional package in module): "SOAP::Transport::" . uc($scheme) . "::Client" @@ -240,9 +240,9 @@ Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION - $Rev: 459 $ + $Rev: 524 $ $LastChangedBy: kutterma $ - $Id: Transport.pm 459 2007-12-16 16:00:14Z kutterma $ + $Id: Transport.pm 524 2008-02-10 23:24:43Z kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Factory/Transport.pm $ - + =cut diff --git a/lib/SOAP/WSDL/Generator/Template/XSD/complexType/variety.tt b/lib/SOAP/WSDL/Generator/Template/XSD/complexType/variety.tt index ffed7e3..cb255ce 100644 --- a/lib/SOAP/WSDL/Generator/Template/XSD/complexType/variety.tt +++ b/lib/SOAP/WSDL/Generator/Template/XSD/complexType/variety.tt @@ -9,7 +9,12 @@ ELSIF (complexType.get_variety == 'choice'); INCLUDE complexType/all.tt(complexType = complexType); ELSIF (complexType.get_variety); THROW NOT_IMPLEMENTED, "Unknown variety ${ complexType.get_variety } in ${ complexType.get_name } (${ element.get_name })"; -ELSE; - # There's no variety - might be empty complexType -END; -%] \ No newline at end of file +ELSE %] + +# There's no variety - empty complexType +use Class::Std::Fast::Storable constructor => 'none'; +use base qw(SOAP::WSDL::XSD::Typelib::ComplexType); + +__PACKAGE__->_factory(); + +[% END %] \ No newline at end of file diff --git a/lib/SOAP/WSDL/Manual/WS_I.pod b/lib/SOAP/WSDL/Manual/WS_I.pod index 88b78bd..4af8c2d 100644 --- a/lib/SOAP/WSDL/Manual/WS_I.pod +++ b/lib/SOAP/WSDL/Manual/WS_I.pod @@ -34,11 +34,11 @@ considered as bugs. =item * RULES NOT APPLICABLE WS-I Basic Profile contains rules for web services as a whole. SOAP::WSDL only -plays the part of one layer in a Web Service CONSUMER, thus does not implement -some parts the WS-I Basic Profile references. +plays the part of one layer in a Web Service CONSUMER / RECEIVER, thus does +not implement some parts the WS-I Basic Profile references. This section contains rules not applicable for SOAP::WSDL, because they refer -parts to web service SOAP::WSDL does not implement. +to parts SOAP::WSDL does not implement. =back @@ -427,9 +427,10 @@ TODO support rpc-literal bindings. In a DESCRIPTION the value of the location attribute of a wsdl:import element SHOULD be treated as a hint. -SOAP::WSDL's schema parser does not handle import elements yet. +The wsdl:import element imports the referenced WSDL definition. -TODO implement support for wsdl:import in SOAP::WSDL::Expat::WSDLParser. +This is rather hard-wired and does not allow to specify a wsdl:import without +a resolvable location. =head2 R4002 @@ -448,9 +449,7 @@ TODO Test whether UTF-16 works. The wsdl:documentation element MAY occur as a child of the wsdl:import element in a DESCRIPTION. -SOAP::WSDL's schema parser does not handle import elements yet. - -TODO implement support for wsdl:import in SOAP::WSDL::Expat::WSDLParser. +Not tested yet. =head2 R2024 @@ -681,7 +680,11 @@ is Schema valid. A DESCRIPTION MUST only use the WSDL "import" statement to import another WSDL description. -SOAP::WSDL has no means of generating WSDL definitions +SOAP::WSDL (partially) supports the wsdl:import statement. The wsdl:include +statement is not supported (yet). + +It's the responsibility of the WSDL author to use only the wsdl:import +statement for importing WSDL descriptions. =head2 R2002 @@ -1249,9 +1252,9 @@ Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION - $Rev: 478 $ + $Rev: 514 $ $LastChangedBy: kutterma $ - $Id: WS_I.pod 478 2007-12-27 14:15:01Z kutterma $ + $Id: WS_I.pod 514 2008-01-31 19:57:52Z kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Manual/WS_I.pod $ =cut diff --git a/lib/SOAP/WSDL/Serializer/XSD.pm b/lib/SOAP/WSDL/Serializer/XSD.pm index 2f9bba8..64384f6 100644 --- a/lib/SOAP/WSDL/Serializer/XSD.pm +++ b/lib/SOAP/WSDL/Serializer/XSD.pm @@ -5,6 +5,7 @@ use warnings; use Class::Std::Fast::Storable; use Scalar::Util qw(blessed); our $VERSION=q{2.00_27}; +use SOAP::WSDL::Factory::Serializer; my $SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/'; my $XML_INSTANCE_NS = 'http://www.w3.org/2001/XMLSchema-instance'; @@ -119,9 +120,9 @@ Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION - $Rev: 477 $ + $Rev: 510 $ $LastChangedBy: kutterma $ - $Id: XSD.pm 477 2007-12-24 10:23:52Z kutterma $ + $Id: XSD.pm 510 2008-01-29 08:03:46Z kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Serializer/XSD.pm $ =cut diff --git a/lib/SOAP/WSDL/TypeLookup.pm b/lib/SOAP/WSDL/TypeLookup.pm index 45d1f98..92745aa 100644 --- a/lib/SOAP/WSDL/TypeLookup.pm +++ b/lib/SOAP/WSDL/TypeLookup.pm @@ -2,11 +2,15 @@ package SOAP::WSDL::TypeLookup; use strict; use warnings; -our $VERSION=q{2.00_29}; +our $VERSION=q{2.00_31}; my %TYPES = ( # wsdl: 'http://schemas.xmlsoap.org/wsdl/' => { + 'import' => { + type => 'HANDLER', + method => 'wsdl_import', + }, binding => { type => 'CLASS', class => 'SOAP::WSDL::Binding', @@ -83,6 +87,10 @@ my %TYPES = ( } }, 'http://www.w3.org/2001/XMLSchema' => { + 'import' => { + type => 'HANDLER', + method => 'xml_schema_import', + }, schema => { type => 'CLASS', class => 'SOAP::WSDL::XSD::Schema', diff --git a/lib/SOAP/WSDL/XSD/Builtin.pm b/lib/SOAP/WSDL/XSD/Builtin.pm index 7929cc1..b7e1ccb 100644 --- a/lib/SOAP/WSDL/XSD/Builtin.pm +++ b/lib/SOAP/WSDL/XSD/Builtin.pm @@ -18,7 +18,7 @@ sub serialize { my $prefix = $prefix_of{ $ns } || die 'No prefix found for namespace '. $ns; $xml .= ' type="' . $prefix . ':' - . $self->get_name() . '"' if ($self->get_name() ); + . $self->get_name() . '"'; } if (defined $value) { diff --git a/lib/SOAP/WSDL/XSD/ComplexType.pm b/lib/SOAP/WSDL/XSD/ComplexType.pm index 877447f..cc01b6e 100644 --- a/lib/SOAP/WSDL/XSD/ComplexType.pm +++ b/lib/SOAP/WSDL/XSD/ComplexType.pm @@ -6,7 +6,7 @@ use Class::Std::Fast::Storable; use Scalar::Util qw(blessed); use base qw/SOAP::WSDL::Base/; -our $VERSION=q{2.00_25}; +our $VERSION=q{2.00_29}; my %annotation_of :ATTR(:name :default<()>); my %attribute_of :ATTR(:name :default<()>); diff --git a/lib/SOAP/WSDL/XSD/Element.pm b/lib/SOAP/WSDL/XSD/Element.pm index db2cf61..c83fa33 100644 --- a/lib/SOAP/WSDL/XSD/Element.pm +++ b/lib/SOAP/WSDL/XSD/Element.pm @@ -53,7 +53,7 @@ sub serialize { # TODO: implement final and substitutionGroup - maybe never implement # substitutionGroup ? - $name ||= $self->get_name(); + $name = $self->get_name() if not ($name); if ( $opt->{ qualify } ) { $opt->{ attributes } = [ ' xmlns="' . $self->get_targetNamespace .'"' ]; diff --git a/lib/SOAP/WSDL/XSD/Typelib/Attribute.pm b/lib/SOAP/WSDL/XSD/Typelib/Attribute.pm index 03dfd4d..5963802 100644 --- a/lib/SOAP/WSDL/XSD/Typelib/Attribute.pm +++ b/lib/SOAP/WSDL/XSD/Typelib/Attribute.pm @@ -4,6 +4,8 @@ use warnings; use base qw(SOAP::WSDL::XSD::Typelib::Element); +our $VERSION=q{2.00_29}; + sub start_tag { # my ($self, $opt, $value) = @_; return q{} if (@_ < 3); diff --git a/lib/SOAP/WSDL/XSD/Typelib/AttributeSet.pm b/lib/SOAP/WSDL/XSD/Typelib/AttributeSet.pm index a6833f1..66e658a 100644 --- a/lib/SOAP/WSDL/XSD/Typelib/AttributeSet.pm +++ b/lib/SOAP/WSDL/XSD/Typelib/AttributeSet.pm @@ -3,6 +3,8 @@ use strict; use warnings; use base qw(SOAP::WSDL::XSD::Typelib::ComplexType); +our $VERSION=q{2.00_29}; + sub serialize { # we work on @_ for performance. $_[1] ||= {}; # $option_ref diff --git a/lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm b/lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm index 310301c..b2f3186 100644 --- a/lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm +++ b/lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm @@ -9,7 +9,7 @@ require Class::Std::Fast::Storable; use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anyType); -our $VERSION = '2.00_29'; +our $VERSION = '2.00_31'; my %ELEMENTS_FROM; my %ATTRIBUTES_OF; @@ -45,6 +45,10 @@ my %xml_attr_of :ATTR(); sub attr { my $self = shift; my $class = ref $self; + + # disable strictness - in perl 5.10 %{ "$foo\::_bar" } triggers a + # symbolic reference error with strictness enabled + no strict qw(refs); die "$class has no attributes" if not defined %{ "$class\::_ATTR::"}; if (@_) { # setter @@ -176,7 +180,7 @@ sub _factory { : die croak "cannot use $is_ref reference as value for $name - $type required" # not $is_ref - : $type->new({ value => $_[1] }); + : defined $_[1] ? $type->new({ value => $_[1] }) : () ; return; }; @@ -223,7 +227,7 @@ sub _factory { : $_ =~ m{ \A # beginning of string xmlns # xmlns }xms # get_elements is inlined for performance. - ? do {} + ? () : do { use Data::Dumper; croak "unknown field $_ in $class. Valid fields are:\n" . join(', ', @{ $ELEMENTS_FROM{ $class } }) . "\n" @@ -455,9 +459,9 @@ Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION - $Rev: 497 $ + $Rev: 524 $ $LastChangedBy: kutterma $ - $Id: ComplexType.pm 497 2008-01-19 12:57:57Z kutterma $ + $Id: ComplexType.pm 524 2008-02-10 23:24:43Z kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm $ =cut diff --git a/lib/SOAP/WSDL/XSD/Typelib/Element.pm b/lib/SOAP/WSDL/XSD/Typelib/Element.pm index c1f48a3..74a27ad 100644 --- a/lib/SOAP/WSDL/XSD/Typelib/Element.pm +++ b/lib/SOAP/WSDL/XSD/Typelib/Element.pm @@ -175,9 +175,9 @@ Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION - $Rev: 497 $ + $Rev: 498 $ $LastChangedBy: kutterma $ - $Id: Element.pm 497 2008-01-19 12:57:57Z kutterma $ + $Id: Element.pm 498 2008-01-20 22:47:18Z kutterma $ $HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/XSD/Typelib/Element.pm $ =cut diff --git a/patches/Manual.diff b/patches/Manual.diff deleted file mode 100644 index 76c8772..0000000 --- a/patches/Manual.diff +++ /dev/null @@ -1,44 +0,0 @@ ---- Manual.pod-orig 2007-12-04 00:45:33.000000000 -0500 -+++ Manual.pod 2007-12-04 00:53:12.000000000 -0500 -@@ -37,7 +37,7 @@ - objects based on SOAP::WSDL's XML schema implementation. - - To access the object's properties use get_NAME / set_NAME getter/setter --methods whith NAME corresponding to the XML tag name / the hash structure as -+methods with NAME corresponding to the XML tag name / the hash structure as - showed in the generated pod. - - =item * Run script -@@ -91,7 +91,7 @@ - - There should be a bunch of classes for types (in the MyTypes:: namespace by - default), elements (in MyElements::), and at least one typemap (in --MyTypemaps::) and one ore more interface classes (in MyInterfaces::). -+MyTypemaps::) and one or more interface classes (in MyInterfaces::). - - If you don't already know the details of the web service you're going to - instrument, it's now time to read the perldoc of the generated interface -@@ -111,7 +111,7 @@ - print $result; - - The above handling of errors ("die $result if not $result") may look a bit --strange - it is due to the nature of -+strange - it is due to the nature of the - L - objects SOAP::WSDL uses for signalling failure. - -@@ -144,12 +144,12 @@ - only implement a few by hand. These (precious) few classes may get lost in - the mass of (cheap) generated ones. Just imagine one of your co-workers (or - even yourself) deleting the whole bunch and re-generating everything - oops --- almost everything. You got the point. -+- almost everything. You get the point. - - For simplicity, you probably just want to use builtin types wherever possible - - you are probably not interested in whether a fault detail's error code is - presented to you as a simpleType ranging from 1 to 10 (which you have to --write) or as a int (which is a builtin type ready to use). -+write) or as an int (which is a builtin type ready to use). - - Using builtin types for simpleType definitions may greatly reduce the number - of additional classes you need to implement. diff --git a/t/006_client.t b/t/006_client.t index 61351a6..a14fbb4 100644 --- a/t/006_client.t +++ b/t/006_client.t @@ -4,23 +4,26 @@ use warnings; use diagnostics; use Test::More tests => 17; # qw/no_plan/; # TODO: change to tests => N; use lib '../lib'; - +use File::Spec; +use File::Basename qw(dirname); eval { require Test::XML; import Test::XML }; -use Cwd; -my $path = cwd; -$path =~s|\/t\/?$||; # allow running from t/ and above (Build test) +my $path = File::Spec->rel2abs( dirname __FILE__ ); +my ($volume, $dir) = File::Spec->splitpath($path, 1); +my @dir_from = File::Spec->splitdir($dir); +unshift @dir_from, $volume if $volume; +my $url = join '/', @dir_from; use_ok(qw/SOAP::WSDL/); -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 +my $soap; +$soap = SOAP::WSDL->new( + wsdl => 'file:///' . $url .'/acceptance/wsdl/006_sax_client.wsdl', + outputxml => 1, # required, if not set ::SOM serializer will be loaded )->wsdlinit(); $soap->servicename('MessageGateway'); @@ -96,7 +99,7 @@ SKIP: { 'MMessageContent' => 'TestContent for Message' , } } - ); + ); ok $result->isa('SOAP::SOM'); is $result->result()->{MMessageContent}, 'TestContent for Message'; is $result->result()->{MRecipientURI}, 'mailto:test@example.com'; diff --git a/t/016_client_object.t b/t/016_client_object.t index c8cbc86..fde6e06 100644 --- a/t/016_client_object.t +++ b/t/016_client_object.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -use Test::More tests => 9; +use Test::More tests => 10; use strict; use lib 'lib/'; use lib '../lib/'; @@ -48,16 +48,23 @@ ok $result->isa('SOAP::WSDL::SOAP::Typelib::Fault11'), 'return fault on impossible call'; ok ! $result, 'fault is false in boolean context'; -package FakeResolver; -sub get_class { - my %class_list = ( +# $soap->no_dispatch(1); +ok ! $soap->call('Test'), 'second call'; + +package FakeResolver; +my %class_list = ( 'Fault' => 'SOAP::WSDL::SOAP::Typelib::Fault11', 'Fault/faultactor' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/faultcode' => 'SOAP::WSDL::XSD::Typelib::Builtin::anyURI', 'Fault/faultstring' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'Fault/detail' => 'SOAP::WSDL::XSD::Typelib::Builtin::anyType', ); +sub get_class { + return $class_list{ $_[1] }; } +sub get_typemap { + return \%class_list; +} diff --git a/t/SOAP/WSDL.t b/t/SOAP/WSDL.t index b0684f0..90e2cf9 100644 --- a/t/SOAP/WSDL.t +++ b/t/SOAP/WSDL.t @@ -2,11 +2,11 @@ use strict; use warnings; use Test::More tests => 12; use File::Spec; -use File::Basename; +use File::Basename qw(dirname); use_ok qw(SOAP::WSDL); my $path = File::Spec->rel2abs(dirname( __FILE__ ) ); - +$path =~s{\\}{/}xmsg; # fix for windows my $soap = SOAP::WSDL->new(); $soap->wsdl("file://$path/WSDL_NOT_FOUND.wsdl"); diff --git a/t/SOAP/WSDL/02_port.t b/t/SOAP/WSDL/02_port.t index 28826cf..90ef1c8 100644 --- a/t/SOAP/WSDL/02_port.t +++ b/t/SOAP/WSDL/02_port.t @@ -1,4 +1,4 @@ -use Test::More tests => 7; +use Test::More tests => 10; use strict; use warnings; use diagnostics; @@ -28,4 +28,13 @@ ok( $soap->wsdlinit(), 'parsed WSDL' ); ok( $soap->wsdlinit( servicename => 'testService', portname => 'testPort'), 'parsed WSDL' ); -ok( ($soap->portname() eq 'testPort' ), 'found port passed to wsdlinit'); \ No newline at end of file +ok( ($soap->portname() eq 'testPort' ), 'found port passed to wsdlinit'); + +ok( $soap = SOAP::WSDL->new( + wsdl => 'file://' . $url . '/../../acceptance/wsdl/02_port.wsdl' +), 'Instantiated object' ); + +ok( $soap->wsdlinit() ); +$soap->outputxml(1); +eval { $soap->call('test') }; +like $@, qr{type \s tns:testSimpleType1 \s , \s urn:simpleType \s not \s found}xms; \ No newline at end of file diff --git a/t/SOAP/WSDL/04_element.t b/t/SOAP/WSDL/04_element.t index da6e0ab..9225bb4 100644 --- a/t/SOAP/WSDL/04_element.t +++ b/t/SOAP/WSDL/04_element.t @@ -1,4 +1,4 @@ -use Test::More tests => 8; +use Test::More tests => 9; use strict; use warnings; use lib '../lib'; @@ -28,7 +28,11 @@ ok( $soap = SOAP::WSDL->new( ), 'Instantiated object' ); #3 -$soap->readable(1); +SKIP: { + skip 'Cannot test warning without Test::Warn', 1 if not (eval "require Test::Warn"); + Test::Warn::warning_like( sub { $soap->readable(1) }, + qr{\A 'readable' \s has \s no \s effect \s any \s more}xms); +} $soap->outputxml(1); ok( $soap->wsdlinit( @@ -36,15 +40,15 @@ ok( $soap->wsdlinit( ), 'parsed WSDL' ); $soap->no_dispatch(1); -ok ($xml = $soap->call('test', +ok ($xml = $soap->call('test', testElement1 => 'Test' ), 'Serialized (simple) element' ); -ok ($xml = $soap->call('testRef', +ok ($xml = $soap->call('testRef', testElementRef => 'Test' ), 'Serialized (simple) element' ); -like $xml +like $xml , qr{Test} , 'element ref serialization result' ; @@ -52,10 +56,10 @@ like $xml TODO: { local $TODO="implement min/maxOccurs checks"; - eval { - $xml = $soap->call('test', + eval { + $xml = $soap->call('test', testAll => [ 'Test 2', 'Test 3' ] - ); + ); }; ok( ($@ =~m/illegal\snumber\sof\selements/), @@ -63,7 +67,7 @@ TODO: { ); eval { - $xml = $soap->call('test', testAll => undef ); + $xml = $soap->call('test', testAll => undef ); }; ok($@, 'Died on illegal number of elements (not enough)'); } diff --git a/t/SOAP/WSDL/Client.t b/t/SOAP/WSDL/Client.t index 618552c..b9d2824 100644 --- a/t/SOAP/WSDL/Client.t +++ b/t/SOAP/WSDL/Client.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 4; #qw(no_plan); +use Test::More tests => 8; #qw(no_plan); use_ok qw(SOAP::WSDL::Client); @@ -10,4 +10,28 @@ ok $client = SOAP::WSDL::Client->new({ proxy => 'http://localhost', }); -is $client->get_endpoint(), 'http://localhost'; \ No newline at end of file +is $client->get_endpoint(), 'http://localhost'; + +$client->no_dispatch(1); +$client->set_serializer('main'); +my $serialize = $client->call({ + operation => 'testMethod' +}, { foo => 'bar'}, { bar => 'baz'}); +is $serialize->{ body }->{ foo }, 'bar'; +is $serialize->{ header }->{ bar }, 'baz'; + +# Old calling style compatibility test - foo => bar is body... +$serialize = $client->call({ + operation => 'testMethod' +}, foo => 'bar'); +is $serialize->{ body }->{ foo }, 'bar'; + +# Old calling style compatibility test - foo => bar is body... +$serialize = $client->call('testMethod', foo => 'bar'); +is $serialize->{ body }->{ foo }, 'bar'; + + +sub serialize { + my $self = shift; + return shift; +} diff --git a/t/SOAP/WSDL/Client/Base.t b/t/SOAP/WSDL/Client/Base.t index 4932334..e8c2be5 100644 --- a/t/SOAP/WSDL/Client/Base.t +++ b/t/SOAP/WSDL/Client/Base.t @@ -4,11 +4,9 @@ use Class::Std::Fast; package main; use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 21; use_ok qw(SOAP::WSDL::Client::Base); -my $client = SOAP::WSDL::Client::Base->new(); - { no warnings qw(redefine once); *SOAP::WSDL::Client::call = sub { is $_[1]->{ operation }, 'sayHello', 'Called method'; @@ -16,35 +14,41 @@ my $client = SOAP::WSDL::Client::Base->new(); }; } +my $client = SOAP::WSDL::Client::Base->new(); + my @result = $client->call({ operation => 'sayHello', soap_action => 'urn:HelloWorld#sayHello', style => 'document', body => { - + 'use' => 'literal', namespace => '', encodingStyle => '', - parts => [qw( SOAP::WSDL::XSD::Typelib::Builtin::string )], + parts => [qw( SOAP::WSDL::XSD::Typelib::Builtin::string + SOAP::WSDL::XSD::Typelib::Builtin::string + )], }, header => { - parts => [qw( SOAP::WSDL::XSD::Typelib::Builtin::string )], + parts => [qw( SOAP::WSDL::XSD::Typelib::Builtin::string + + )], }, headerfault => { - + } }, { value => 'Body' }, { value => 'Header' }); -is $result[0], 'Body'; +is $result[0]->[0], 'Body'; is $result[1], 'Header'; -isa_ok $result[0], 'SOAP::WSDL::XSD::Typelib::Builtin::string'; +isa_ok $result[0]->[0], 'SOAP::WSDL::XSD::Typelib::Builtin::string'; @result = $client->call({ operation => 'sayHello', soap_action => 'urn:HelloWorld#sayHello', style => 'document', body => { - + 'use' => 'literal', namespace => '', encodingStyle => '', @@ -54,9 +58,9 @@ isa_ok $result[0], 'SOAP::WSDL::XSD::Typelib::Builtin::string'; parts => [qw( SOAP::WSDL::XSD::Typelib::Builtin::string )], }, headerfault => { - + } - }, SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Body2' }), + }, SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Body2' }), SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Header2' }) ); @@ -64,3 +68,97 @@ is $result[0], 'Body2'; is $result[1], 'Header2'; isa_ok $result[1], 'SOAP::WSDL::XSD::Typelib::Builtin::string'; +# Call with more body parts than parameters. Body parts are empty +@result = $client->call({ + operation => 'sayHello', + soap_action => 'urn:HelloWorld#sayHello', + style => 'document', + body => { + + 'use' => 'literal', + namespace => '', + encodingStyle => '', + parts => [qw( SOAP::WSDL::XSD::Typelib::Builtin::string )], + }, + header => { + parts => [qw( SOAP::WSDL::XSD::Typelib::Builtin::string )], + }, + headerfault => { + + } + }, [], + SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Header2' }) + ); + +isa_ok $result[0], 'SOAP::WSDL::XSD::Typelib::Builtin::string'; +is $result[0], undef; +is $result[1], 'Header2'; +isa_ok $result[1], 'SOAP::WSDL::XSD::Typelib::Builtin::string'; + +# Call with more body parts than parameters. Body parts are empty +# No header +@result = $client->call({ + operation => 'sayHello', + soap_action => 'urn:HelloWorld#sayHello', + style => 'document', + body => { + + 'use' => 'literal', + namespace => '', + encodingStyle => '', + parts => [qw( SOAP::WSDL::XSD::Typelib::Builtin::string )], + }, + header => { + }, + headerfault => { + + } + }); + +isa_ok $result[0], 'SOAP::WSDL::XSD::Typelib::Builtin::string'; +is $result[0], undef; + +eval { $client->call({ + operation => 'sayHello', + soap_action => 'urn:HelloWorld#sayHello', + style => 'document', + body => { + + 'use' => 'literal', + namespace => '', + encodingStyle => '', + parts => [qw( SomeStupidClassYouProbablyDontHaveOnYourSystem )], + }, + header => { + }, + headerfault => { + + } + }) +}; +like $@, qr{ Can't \s locate }xms; + +isa_ok $result[0], 'SOAP::WSDL::XSD::Typelib::Builtin::string'; +is $result[0], undef; + +eval { $client->call({ + operation => 'sayHello', + soap_action => 'urn:HelloWorld#sayHello', + style => 'document', + body => { + + 'use' => 'literal', + namespace => '', + encodingStyle => '', + parts => [qw( SOAP::WSDL::XSD::Typelib::Builtin::string )], + }, + header => { + parts => [qw( SomeOtherStupidClassYouProbablyDontHaveOnYourSystem )], + }, + headerfault => { + + } + }) +}; +# die $@; +like $@, qr{ Can't \s locate }xms; \ No newline at end of file diff --git a/t/SOAP/WSDL/Definitions.t b/t/SOAP/WSDL/Definitions.t new file mode 100644 index 0000000..035e638 --- /dev/null +++ b/t/SOAP/WSDL/Definitions.t @@ -0,0 +1,32 @@ +use strict; +use warnings; +use Test::More tests => 4; + +use SOAP::WSDL::PortType; +use_ok qw(SOAP::WSDL::Definitions); + +my $obj = SOAP::WSDL::Definitions->new({ + portType => [ + SOAP::WSDL::PortType->new({ + name => 'foo', + targetNamespace => 'bar', + }), + SOAP::WSDL::PortType->new({ + name => 'foo', + targetNamespace => 'baz', + }), + SOAP::WSDL::PortType->new({ + name => 'foobar', + targetNamespace => 'bar', + }), + ] +}); + + +my $found= $obj->find_portType('bar', 'foobar'); +is $found->get_name(), 'foobar', 'found PortType'; +$found = $obj->find_portType('baz', 'foo'); +is $found->get_name(), 'foo', 'found PortType'; + +$found = $obj->find_portType('baz', 'foobar'); +is $found, undef, 'find_PortType returns undef on unknown PortType'; \ No newline at end of file diff --git a/t/SOAP/WSDL/Deserializer/XSD.t b/t/SOAP/WSDL/Deserializer/XSD.t index ac06271..ed3052a 100644 --- a/t/SOAP/WSDL/Deserializer/XSD.t +++ b/t/SOAP/WSDL/Deserializer/XSD.t @@ -4,7 +4,7 @@ package TestResolver; sub get_typemap { {} }; package main; -use Test::More tests => 8; +use Test::More tests => 9; use SOAP::WSDL::Deserializer::XSD; @@ -24,4 +24,7 @@ is $fault->get_faultcode(), 'soap:Client'; isa_ok $obj->deserialize('rubbeldiekatz'), 'SOAP::WSDL::SOAP::Typelib::Fault11'; isa_ok $obj->deserialize(''), 'SOAP::WSDL::SOAP::Typelib::Fault11'; -isa_ok $obj->deserialize(''), 'SOAP::WSDL::SOAP::Typelib::Fault11'; \ No newline at end of file +isa_ok $obj->deserialize(''), 'SOAP::WSDL::SOAP::Typelib::Fault11'; +is $obj->deserialize(' + '), undef, 'Deserialize empty envelope'; \ No newline at end of file diff --git a/t/SOAP/WSDL/Expat/Base.t b/t/SOAP/WSDL/Expat/Base.t index d65f709..d1ed1fc 100644 --- a/t/SOAP/WSDL/Expat/Base.t +++ b/t/SOAP/WSDL/Expat/Base.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 5; use_ok qw(SOAP::WSDL::Expat::Base); my $parser = SOAP::WSDL::Expat::Base->new(); @@ -9,4 +9,13 @@ eval { $parser->parse('Foobar')}; ok $@; eval { $parser->parsefile('Foobar')}; -ok $@; \ No newline at end of file +ok $@; + + +$parser = SOAP::WSDL::Expat::Base->new({ + user_agent => 'foo', +}); + +is $parser->get_user_agent(), 'foo'; +$parser->set_user_agent('bar'); +is $parser->get_user_agent(), 'bar'; diff --git a/t/SOAP/WSDL/Expat/MessageParser.t b/t/SOAP/WSDL/Expat/MessageParser.t index f5e17f7..81bf49b 100644 --- a/t/SOAP/WSDL/Expat/MessageParser.t +++ b/t/SOAP/WSDL/Expat/MessageParser.t @@ -36,20 +36,20 @@ my $xml_attr = q{ Test - Test2 + }; $parser->parse($xml_attr); is $parser->get_data(), - q{TestTest2}, + q{Test}, 'Content with attributes'; my $xml_error = q{ Test - Test2 + Bar }; diff --git a/t/SOAP/WSDL/Expat/WSDLParser.t b/t/SOAP/WSDL/Expat/WSDLParser.t index 323c869..ccef309 100644 --- a/t/SOAP/WSDL/Expat/WSDLParser.t +++ b/t/SOAP/WSDL/Expat/WSDLParser.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 4; #qw(no_plan); +use Test::More tests => 10; #qw(no_plan); use File::Spec; use File::Basename; @@ -10,7 +10,7 @@ use_ok qw( SOAP::WSDL::Expat::WSDLParser); my $parser = SOAP::WSDL::Expat::WSDLParser->new(); -my $definitions = $parser->parse_file( +my $definitions = $parser->parse_file( "$path/../../../acceptance/wsdl/WSDLParser.wsdl" ); @@ -30,16 +30,27 @@ my $generator = SOAP::WSDL::Generator::Template::XSD->new({ OUTPUT_PATH => "$path/testlib", }); -my $code = ""; -$generator->set_output(\$code); -$generator->generate_typelib(); -{ - eval $code; - ok !$@; - print $@ if $@; -} +#my $code = ""; +#$generator->set_output(\$code); +#$generator->generate_typelib(); +#{ +# eval $code; +# ok !$@; +# print $@ if $@; +#} -# print $code; +$definitions = $parser->parse_uri( + "file://$path/../../../acceptance/wsdl/WSDLParser-import.wsdl" +); + +ok my $service = $definitions->first_service(); +is $service->get_name(), 'Service1', 'wsdl:import service name'; +is $definitions->first_binding()->get_name(), 'Service1Soap', 'wsdl:import binding name'; + +ok my $schema_from_ref = $definitions->first_types()->get_schema(); +is @{ $schema_from_ref }, 2, 'got builtin and imported schema'; +ok @{ $schema_from_ref->[1]->get_element } > 0; +is $schema_from_ref->[1]->get_element->[0]->get_name(), 'sayHello'; __END__ diff --git a/t/SOAP/WSDL/Factory/Transport.t b/t/SOAP/WSDL/Factory/Transport.t index 490febd..16b3eb0 100644 --- a/t/SOAP/WSDL/Factory/Transport.t +++ b/t/SOAP/WSDL/Factory/Transport.t @@ -1,9 +1,13 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 6; use Scalar::Util qw(blessed); use SOAP::WSDL::Factory::Transport; +eval { SOAP::WSDL::Factory::Transport->get_transport('') }; +like $@, qr{^no transport}; + + eval { SOAP::WSDL::Factory::Transport->get_transport('zumsl') }; like $@, qr{^no transport}; @@ -12,7 +16,7 @@ ok blessed $obj; SOAP::WSDL::Factory::Transport->register('zumsl', 'Hope_You_Have_No_Such_Package_Installed'); -eval { SOAP::WSDL::Factory::Transport->get_transport('zumsl') }; +eval { SOAP::WSDL::Factory::Transport->get_transport('zumsl:foo') }; like $@, qr{^Cannot load}; eval { SOAP::WSDL::Factory::Transport->register( \'zumsl', 'Foo') }; diff --git a/t/SOAP/WSDL/Generator/Template.t b/t/SOAP/WSDL/Generator/Template.t index c63f24d..16f4c15 100644 --- a/t/SOAP/WSDL/Generator/Template.t +++ b/t/SOAP/WSDL/Generator/Template.t @@ -44,7 +44,7 @@ print $@ if $@; # print $output; __END__ -my $tt = Template->new( +my $tt = Template->new( DEBUG => 1, EVAL_PERL => 1, RECURSION => 1, @@ -53,7 +53,7 @@ my $tt = Template->new( foreach my $service (@{ $definitions->get_service }) { my $output; - $tt->process( 'Interface.tt', { + $tt->process( 'Interface.tt', { definitions => $definitions, service => $service, interface_prefix => 'MyInterface', @@ -62,8 +62,8 @@ foreach my $service (@{ $definitions->get_service }) { element_prefix => 'MyElement', }, \$output); die $tt->error if $tt->error(); - + ok eval $output, 'eval output'; - + print $output; }; \ No newline at end of file diff --git a/t/SOAP/WSDL/Generator/XSD.t b/t/SOAP/WSDL/Generator/XSD.t index ca9b740..74bf8c5 100644 --- a/t/SOAP/WSDL/Generator/XSD.t +++ b/t/SOAP/WSDL/Generator/XSD.t @@ -1,4 +1,4 @@ -use Test::More tests => 38; +use Test::More tests => 41; use File::Basename qw(dirname); use File::Spec; use File::Path; @@ -149,5 +149,12 @@ is $ct_east->get_testAtomicSimpleTypeElement2->get_value(), 23; isa_ok($ct_east->get_testAtomicSimpleTypeElement2, 'MyTypes::testComplexTypeElementAtomicSimpleType::_testAtomicSimpleTypeElement2'); +ok eval { require MyElements::testElementCompletelyEmptyComplex; } + , 'load MyElements::testElementCompletelyEmptyComplex'; +ok my $empty = MyElements::testElementCompletelyEmptyComplex->new(); + +is $empty->serialize_qualified(), '' + , 'serialize empty'; + rmtree "$path/testlib"; diff --git a/t/SOAP/WSDL/PortType.t b/t/SOAP/WSDL/PortType.t new file mode 100644 index 0000000..3bb54eb --- /dev/null +++ b/t/SOAP/WSDL/PortType.t @@ -0,0 +1,32 @@ +use strict; +use warnings; +use Test::More tests => 4; + +use SOAP::WSDL::Operation; +use_ok qw(SOAP::WSDL::PortType); + +my $portType = SOAP::WSDL::PortType->new({ + operation => [ + SOAP::WSDL::Operation->new({ + name => 'foo', + targetNamespace => 'bar', + }), + SOAP::WSDL::Operation->new({ + name => 'foo', + targetNamespace => 'baz', + }), + SOAP::WSDL::Operation->new({ + name => 'foobar', + targetNamespace => 'bar', + }), + ] +}); + + +my $operation = $portType->find_operation('bar', 'foobar'); +is $operation->get_name(), 'foobar', 'found operation'; +$operation = $portType->find_operation('baz', 'foo'); +is $operation->get_name(), 'foo', 'found operation'; + +$operation = $portType->find_operation('baz', 'foobar'); +is $operation, undef, 'find_operation returns undef on unknown operation'; \ No newline at end of file diff --git a/t/SOAP/WSDL/Server.t b/t/SOAP/WSDL/Server.t index 083194a..b4b6d61 100644 --- a/t/SOAP/WSDL/Server.t +++ b/t/SOAP/WSDL/Server.t @@ -55,8 +55,13 @@ eval { $server->handle($request) }; like $@, qr{\A Not \s implemented:}x, 'Not implemented fault caught'; +$server->set_action_map_ref({ Test => 'test'}); +ok $server->handle($request); $server->set_deserializer('MyDeserializer2'); eval { $server->handle(HTTP::Request->new()) }; like $@, qr{\A Error \s deserializing}x, 'Error deserializing caught'; +sub test { + return; +} \ No newline at end of file diff --git a/t/SOAP/WSDL/Server/CGI.t b/t/SOAP/WSDL/Server/CGI.t index 326b5c8..01d3ada 100644 --- a/t/SOAP/WSDL/Server/CGI.t +++ b/t/SOAP/WSDL/Server/CGI.t @@ -11,7 +11,7 @@ use Test::More; eval "require IO::Scalar" or plan skip_all => 'IO::Scalar required for testing...'; -plan tests => 8; +plan tests => 12; use_ok(SOAP::WSDL::Server); use_ok(SOAP::WSDL::Server::CGI); @@ -30,51 +30,113 @@ $server->set_action_map_ref({ my $output = q{}; my $fh = IO::Scalar->new(\$output); my $stdout = *STDOUT; +my $stdin = *STDIN; *STDOUT = $fh; +{ + local %ENV; + $server->handle(); + + like $output, qr{ \A Status: \s 411 \s Length \s Required}x; + $output = q{}; + + $ENV{'CONTENT_LENGTH'} = '0e0'; + $server->handle(); + + like $output, qr{ Error \s deserializing }xsm; + $output = q{}; + + $server->set_action_map_ref({ + 'foo' => 'bar', + }); + $server->set_dispatch_to( 'HandlerClass' ); + + $server->handle(); + like $output, qr{no \s element \s found}xms; + $output = q{}; + + $ENV{REQUEST_METHOD} = 'POST'; + $ENV{HTTP_SOAPACTION} = 'test'; + $server->handle(); + like $output, qr{no \s element \s found}xms; + $output = q{}; + + delete $ENV{HTTP_SOAPACTION}; + + $ENV{EXPECT} = 'Foo'; + $ENV{HTTP_SOAPAction} = 'foo'; + $server->handle(); + + like $output, qr{no \s element \s found}xms; + $output = q{}; + + $ENV{EXPECT} = '100-Continue'; + $ENV{HTTP_SOAPAction} = 'foo'; + $server->handle(); + like $output, qr{100 \s Continue}xms; + $output = q{}; + + delete $ENV{EXPECT}; + + my $input = 'Foobar'; + my $ih = IO::Scalar->new(\$input); + $ih->seek(0); + *STDIN = $ih; + +# my $buffer; +# read(*STDIN, $buffer, 6); +# die $buffer; + $ENV{HTTP_SOAPAction} = 'bar'; + $ENV{CONTENT_LENGTH} = 6; + $server->handle(); + like $output, qr{ Error \s deserializing \s message}xms; + $output = q{}; + $ih->seek(0); -$server->handle(); - -like $output, qr{ \A Status: \s 411 \s Length \s Required}x; -$output = q{}; - -$ENV{'CONTENT_LENGTH'} = '0e0'; -$server->handle(); - -like $output, qr{ Error \s deserializing }xsm; -$output = q{}; - -$server->set_action_map_ref({ - 'foo' => 'bar', -}); -$server->set_dispatch_to( 'HandlerClass' ); - -$server->handle(); -like $output, qr{no \s element \s found}xms; -$output = q{}; - -$ENV{REQUEST_METHOD} = 'POST'; -$ENV{HTTP_SOAPACTION} = 'test'; -$server->handle(); -like $output, qr{no \s element \s found}xms; -$output = q{}; - -delete $ENV{HTTP_SOAPACTION}; - -$ENV{EXPECT} = 'Foo'; -$ENV{HTTP_SOAPAction} = 'foo'; -$server->handle(); - -like $output, qr{no \s element \s found}xms; -$output = q{}; - -$ENV{EXPECT} = '100-Continue'; -$ENV{HTTP_SOAPAction} = 'foo'; -$server->handle(); -like $output, qr{100 \s Continue}xms; -$output = q{}; + $input = q{ + }; + $ENV{HTTP_SOAPAction} = 'bar'; + $ENV{CONTENT_LENGTH} = length $input; + $server->handle(); +# die $output; + like $output, qr{ Not \s found:}xms; + $output = q{}; + $ih->seek(0); + $server->set_dispatch_to( 'HandlerClass' ); + $server->set_action_map_ref({ + 'bar' => 'bar', + }); + $input = q{ + }; + $ENV{HTTP_SOAPAction} = q{"bar"}; + $ENV{CONTENT_LENGTH} = length $input; + $server->handle(); + use Data::Dumper; + like $output, qr{ \A Status: \s 200 \s OK}xms; + $output = q{}; + $ih->seek(0); + + + $server->set_dispatch_to( 'HandlerClass' ); + $server->set_action_map_ref({ + 'bar' => 'bar', + }); + $input = q{ + }; + $ENV{SERVER_SOFTWARE} ='IIS Foobar'; + $ENV{HTTP_SOAPAction} = q{"bar"}; + $ENV{CONTENT_LENGTH} = length $input; + $server->handle(); + use Data::Dumper; + like $output, qr{ \A HTTP/1.0 \s 200 \s OK}xms; + $output = q{}; + $ih->seek(0); + +} + +# restore handles *STDOUT = $stdout; - +*STDIN = $stdin; # print $output; \ No newline at end of file diff --git a/t/SOAP/WSDL/XSD/Attribute.t b/t/SOAP/WSDL/XSD/Attribute.t new file mode 100644 index 0000000..6dfc0b8 --- /dev/null +++ b/t/SOAP/WSDL/XSD/Attribute.t @@ -0,0 +1,40 @@ +use strict; +use warnings; +use Test::More tests => 2; #qw(no_plan); + +use_ok qw(SOAP::WSDL::XSD::Attribute); + +use SOAP::WSDL::Expat::WSDLParser; +my $parser = SOAP::WSDL::Expat::WSDLParser->new(); + +my $xml = q{ + + + + + + + + + + + + + + + + + + +}; + +my $schema = $parser->parse($xml); + +is $schema->find_element('urn:HelloWorld', 'sayHello') + ->first_complexType() + ->first_attribute()->get_name(), + 'testAttr', 'found attribute'; \ No newline at end of file diff --git a/t/SOAP/WSDL/XSD/Element.t b/t/SOAP/WSDL/XSD/Element.t index a8837a6..3fd01d4 100644 --- a/t/SOAP/WSDL/XSD/Element.t +++ b/t/SOAP/WSDL/XSD/Element.t @@ -1,11 +1,11 @@ package Foo; sub serialize { - return "serialized $_[1] $_[2]"; + return "serialized $_[1] $_[2]" . join ' ', @{$_[3]->{ attributes } || [] } if $_[3]; } package main; use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 16; use_ok qw(SOAP::WSDL::XSD::Element); @@ -16,6 +16,9 @@ is $element->first_simpleType(), undef; $element->set_simpleType('Foo'); is $element->first_simpleType(), 'Foo'; +is $element->serialize('Foobar', 'Bar', { namespace => {} } ), 'serialized Foobar Bar'; +is $element->serialize('Foobar', undef, { namespace => {} } ), 'serialized Foobar '; + $element->set_simpleType( [ 'Foo', 'Bar' ]); is $element->first_simpleType(), 'Foo'; @@ -30,6 +33,13 @@ is $element->first_complexType(), 'Foo'; $element->set_default('Foo'); is $element->serialize('Foobar', undef, { namespace => {} } ), 'serialized Foobar Foo'; +$element->set_targetNamespace('urn:foobar'); +is $element->serialize('Foobar', undef, { namespace => {}, qualify => 1 } ), 'serialized Foobar Foo xmlns="urn:foobar"'; + +$element->set_targetNamespace('urn:foobar'); +is $element->serialize('Foobar', 'Bar', { namespace => {}, qualify => 1 } ), 'serialized Foobar Bar xmlns="urn:foobar"'; + + $element->set_name('Bar'); is $element->serialize(undef, undef, { namespace => {} } ), 'serialized Bar Foo'; diff --git a/t/SOAP/WSDL/XSD/Schema.t b/t/SOAP/WSDL/XSD/Schema.t new file mode 100644 index 0000000..89dd9d3 --- /dev/null +++ b/t/SOAP/WSDL/XSD/Schema.t @@ -0,0 +1,32 @@ +use strict; +use warnings; +use Test::More tests => 4; + +use SOAP::WSDL::XSD::Element; +use_ok qw(SOAP::WSDL::XSD::Schema); + +my $obj = SOAP::WSDL::XSD::Schema->new({ + element => [ + SOAP::WSDL::XSD::Element->new({ + name => 'foo', + targetNamespace => 'bar', + }), + SOAP::WSDL::XSD::Element->new({ + name => 'foo', + targetNamespace => 'baz', + }), + SOAP::WSDL::XSD::Element->new({ + name => 'foobar', + targetNamespace => 'bar', + }), + ] +}); + + +my $found= $obj->find_element('bar', 'foobar'); +is $found->get_name(), 'foobar', 'found Element'; +$found = $obj->find_element('baz', 'foo'); +is $found->get_name(), 'foo', 'found Element'; + +$found = $obj->find_element('baz', 'foobar'); +is $found, undef, 'find_Element returns undef on unknown Element'; \ No newline at end of file diff --git a/t/SOAP/WSDL/XSD/Typelib/ComplexType.t b/t/SOAP/WSDL/XSD/Typelib/ComplexType.t index 9b35209..819a38f 100644 --- a/t/SOAP/WSDL/XSD/Typelib/ComplexType.t +++ b/t/SOAP/WSDL/XSD/Typelib/ComplexType.t @@ -18,7 +18,7 @@ package MyType; use base qw(SOAP::WSDL::XSD::Typelib::ComplexType); { my %test_of :ATTR(:get); - + __PACKAGE__->_factory( [ 'test' ], { test => \%test_of, }, @@ -41,11 +41,11 @@ use base qw(SOAP::WSDL::XSD::Typelib::AttributeSet); my %test2_of :ATTR(:get); __PACKAGE__->_factory( [ 'test', 'test2' ], - { + { test => \%test_of, test2 => \%test2_of, }, - { + { test => 'SOAP::WSDL::XSD::Typelib::Builtin::string', test2 => 'MyAttribute', } @@ -68,21 +68,18 @@ __PACKAGE__->_factory( ); package main; -use Test::More tests => 106; +use Test::More tests => 109; use Storable; my $have_warn = eval { require Test::Warn; import Test::Warn; 1; }; my $obj; -$obj = MyEmptyType->new(); -is $obj->serialize, ''; -is $obj->serialize({ name => 'test'}), ''; - -$obj = MyEmptyType2->new(); -is $obj->serialize, ''; -is $obj->serialize({ name => 'test'}), ''; - +for my $class (qw{MyEmptyType MyEmptyType2}) { + $obj = $class->new(); + is $obj->serialize, '', "$class object serializes to q{}"; + is $obj->serialize({ name => 'test'}), '', "$class object serializes to with name=test"; +} $obj = MyType->new({}); isa_ok $obj, 'MyType'; @@ -101,16 +98,17 @@ isa_ok $obj, 'MyType'; isa_ok $obj->get_test, 'SOAP::WSDL::XSD::Typelib::Builtin::string'; is $obj->get_test, 'Test1', 'element content'; -$obj = MyType->new({ - test => SOAP::WSDL::XSD::Typelib::Builtin::string->new({ +$obj = MyType->new({ + test => SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Test2' }) }); + isa_ok $obj, 'MyType'; isa_ok $obj->get_test, 'SOAP::WSDL::XSD::Typelib::Builtin::string'; is $obj->get_test, 'Test2', 'element content'; -$obj = MyType->new({ +$obj = MyType->new({ test => { value => 'Test2' } # just a trick - pass it unaltered to new... }); isa_ok $obj, 'MyType'; @@ -120,17 +118,18 @@ is $obj->get_test, 'Test2', 'element content'; $hash_of_ref = $obj->as_hash_ref(); is $hash_of_ref->{ test }, 'Test2'; -$obj = MyType->new({ +$obj = MyType->new({ test => [ - SOAP::WSDL::XSD::Typelib::Builtin::string->new({ + SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Test' }), - SOAP::WSDL::XSD::Typelib::Builtin::string->new({ + SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Test2' }) ], }); + isa_ok $obj, 'MyType'; isa_ok $obj->get_test, 'ARRAY'; is $obj->get_test()->[0], 'Test', 'element content (list content [0])'; @@ -154,24 +153,21 @@ is $nested->get_test->[0], $obj; $nested = MyType2->new({ test => { test => [ - SOAP::WSDL::XSD::Typelib::Builtin::string->new({ + SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Test' }), - - SOAP::WSDL::XSD::Typelib::Builtin::string->new({ + + SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Test2' }) ], - }, + }, }); - $hash_of_ref = $nested->as_hash_ref(); is $hash_of_ref->{ test }->{ test }->[1], 'Test2'; -# isnt $nested->get_test->[0], $obj, 'element identity'; - $obj = MyType->new(); isa_ok $obj, 'MyType'; is $obj->get_test, undef, 'undefined element content'; @@ -197,6 +193,11 @@ for my $count (1..5) { $obj->set_test(); is $obj->get_test, (), 'removed element content'; +$obj = MyEmptyType->new(); +eval { + isa_ok $obj->attr() , 'SOAP::WSDL::XSD::Typelib::AttributeSet'; +}; +like $@, qr{\s has \s no \s attributes}x; $obj = MyElement->new(); isa_ok $obj->attr() , 'SOAP::WSDL::XSD::Typelib::AttributeSet'; @@ -212,7 +213,7 @@ is $obj->serialize(), 'Serialization with attributes'; $obj->attr()->set_test2('test'); -is $obj->serialize(), +is $obj->serialize(), q{}, 'Serialization with attributes'; @@ -227,7 +228,7 @@ is $obj->get_test, undef; eval { $foo = @{ $obj->get_test() } }; if (! $@) { is $foo, undef; - } + } else { like $@ , qr{Can't \s use \s an \s undefined}x, 'get_ELEMENT still undef on ARRAYIFY'; } @@ -260,13 +261,18 @@ for my $count (1..5) { is $obj->get_test->[$index], "TestString$index"; } is $obj->serialize(), $serialized[$count -1]; - + } +my $clone = Storable::thaw( Storable::freeze( $obj )); +is $clone->get_test()->[0], 'TestString0'; + +## failure tests + eval { - $obj = MyType->new({ + $obj = MyType->new({ test => [ - SOAP::WSDL::XSD::Typelib::Builtin::string->new({ + SOAP::WSDL::XSD::Typelib::Builtin::string->new({ value => 'Test' }), @@ -277,14 +283,22 @@ eval { like $@, qr{cannot \s use \s CODE}xms; eval { - $obj = MyType->new({ + $obj = MyType->new({ test => \&CORE::die, }); }; like $@, qr{cannot \s use \s CODE}xms; +# TODO ignore XMLNS (for now) +$obj = MyType->new({ xmlns => 'fubar'}); +ok defined $obj; +TODO: { + local $TODO = "Support XML namespaces"; + is $obj->get_xmlns(), 'fubar'; +} + eval { - $obj = MyType->new({ + $obj = MyType->new({ foobar => 'fubar' }); }; @@ -300,16 +314,13 @@ like $@, qr{Can't \s locate \s object \s method}x; eval { MyType->new({ FOO => 42 }) }; like $@, qr{unknown \s field \s}xm; -my $clone = Storable::thaw( Storable::freeze( $obj )); -is $clone->get_test()->[0], 'TestString0'; - eval { SOAP::WSDL::XSD::Typelib::ComplexType::AUTOMETHOD() }; like $@, qr{Cannot \s call}xm; - eval { SOAP::WSDL::XSD::Typelib::ComplexType->_factory([], { test => {} }, {}) }; like $@, qr{ No \s class \s given \s for \s }xms; eval { SOAP::WSDL::XSD::Typelib::ComplexType->_factory([], { test => {} }, { test => 'HopeItDoesntExistOnYourSystem'}) }; like $@, qr{ Can't \s locate \s HopeItDoesntExistOnYourSystem.pm }xms; +# print Dumper diff --git a/t/acceptance/wsdl/WSDLParser-import.wsdl b/t/acceptance/wsdl/WSDLParser-import.wsdl new file mode 100644 index 0000000..4379bc9 --- /dev/null +++ b/t/acceptance/wsdl/WSDLParser-import.wsdl @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/t/acceptance/wsdl/WSDLParser-imported.wsdl b/t/acceptance/wsdl/WSDLParser-imported.wsdl new file mode 100644 index 0000000..f642126 --- /dev/null +++ b/t/acceptance/wsdl/WSDLParser-imported.wsdl @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/t/acceptance/wsdl/generator_test.wsdl b/t/acceptance/wsdl/generator_test.wsdl index 8df1a85..fb75335 100644 --- a/t/acceptance/wsdl/generator_test.wsdl +++ b/t/acceptance/wsdl/generator_test.wsdl @@ -201,6 +201,15 @@ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xm + + + + + + + + + diff --git a/t/acceptance/wsdl/import.xsd b/t/acceptance/wsdl/import.xsd new file mode 100644 index 0000000..2cb72d4 --- /dev/null +++ b/t/acceptance/wsdl/import.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + +