import SOAP-WSDL 2.00_27 from CPAN

git-cpan-module:   SOAP-WSDL
git-cpan-version:  2.00_27
git-cpan-authorid: MKUTTER
git-cpan-file:     authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_27.tar.gz
This commit is contained in:
Martin Kutter
2007-12-19 14:17:23 -08:00
committed by Michael G. Schwern
parent 3cfeebae54
commit eb096ad88e
67 changed files with 1147 additions and 277 deletions

View File

@@ -669,16 +669,16 @@ The following facets have no influence yet:
=item * L<SOAP::Lite|SOAP::Lite>
Full featured SOAP-library, little WSDL support. Supports rpc-encoded style only. Many protocols supported.
Full featured SOAP-library, little WSDL support. Supports rpc-encoded style
only. Many protocols supported.
=item * L<XML::Compile::WSDL|XML::Compile::WSDL> / L<XML::Compile::SOAP|XML::Compile::SOAP>
A promising-looking approach derived from a cool functional DOM-based XML schema parser.
Creates parser/generator functions for SOAP messages. Includes SOAP Client
and Server implementatios.
Will support encoding/decoding of SOAP messages based on WSDL definitions.
Not yet finished at the time of writing - but you may wish to give it a try, especially
if you need to adhere very closely to the XML Schema / WSDL specs.
You might want to give it a try, especially if you need to adhere very
closely to the XML Schema / WSDL specs.
=back
@@ -730,9 +730,9 @@ Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
=head1 REPOSITORY INFORMATION
$Rev: 427 $
$Rev: 457 $
$LastChangedBy: kutterma $
$Id: WSDL.pm 427 2007-12-02 22:20:24Z kutterma $
$Id: WSDL.pm 457 2007-12-16 08:02:06Z kutterma $
$HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL.pm $
=cut

View File

@@ -5,7 +5,7 @@ use Class::Std::Fast::Storable;
use List::Util qw(first);
use Carp qw(croak carp confess);
our $VERSION='2.00_25';
our $VERSION='2.00_27';
my %id_of :ATTR(:name<id> :default<()>);
my %name_of :ATTR(:name<name> :default<()>);
@@ -14,6 +14,11 @@ my %targetNamespace_of :ATTR(:name<targetNamespace> :default<()>);
my %xmlns_of :ATTR(:name<xmlns> :default<{}>);
my %parent_of :ATTR(:name<parent> :default<()>);
sub START {
my ($self, $ident, $arg_ref) = @_;
$xmlns_of{ $ident }->{ '#default' } = $self->get_xmlns()->{ '#default' };
}
sub DEMOLISH {
my $self = shift;
# delete upward references
@@ -82,7 +87,7 @@ sub AUTOMETHOD {
return $result_ref->[0];
};
}
confess "$subname not found in class " . (ref $self || $self) ;
confess "$subname not found in class " . ref $self;
}
sub init {
@@ -95,11 +100,6 @@ sub init {
$xmlns_of{ ident $self }->{ $value->{ LocalName } } = $value->{ Value };
next;
}
elsif ($value->{ Name } =~m{^xmlns$}xms) {
# just ignore xmlns = for now
# TODO handle xmlns correctly - maybe via setting a prefix ?
next;
}
my $name = $value->{ LocalName };
my $method = "set_$name";
@@ -110,16 +110,23 @@ sub init {
sub expand {
my ($self, , $qname) = @_;
my $ns_of = $self->get_xmlns();
if (not $qname=~m{:}xm) {
die "un-prefixed element name <$qname> found, but no default namespace set\n"
if not defined $ns_of->{ '#default' };
return $ns_of->{ '#default' }, $qname;
}
my ($prefix, $localname) = split /:/x, $qname;
# my %ns_map = reverse %{ $self->get_xmlns() };
my %ns_map = %{ $self->get_xmlns() };
return ($ns_map{ $prefix }, $localname) if ($ns_map{ $prefix });
return ($ns_of->{ $prefix }, $localname) if ($ns_of->{ $prefix });
if (my $parent = $self->get_parent()) {
return $parent->expand($qname);
}
confess "unbound prefix $prefix found for $prefix:$localname. Bound prefixes are"
. join(', ', keys %ns_map);
. join(', ', keys %{ $ns_of });
}
sub _expand;
*_expand = \&expand;

View File

@@ -11,7 +11,7 @@ use SOAP::WSDL::Factory::Serializer;
use SOAP::WSDL::Factory::Transport;
use SOAP::WSDL::Expat::MessageParser;
our $VERSION = '2.00_25';
our $VERSION = '2.00_27';
my %class_resolver_of :ATTR(:name<class_resolver> :default<()>);
my %no_dispatch_of :ATTR(:name<no_dispatch> :default<()>);
@@ -268,17 +268,6 @@ Default:
text/xml; charset: utf8
=head3 set_trace
$soap->set_trace(1);
$soap->set_trace( sub { Log::Log4perl::get_logger()->debug( @_ ) } );
When set to a true value, tracing (via warn) is enabled.
When set to a code reference, this function will be called on every
trace call, making it really easy for you to set up log4perl logging
or whatever you need.
=head2 Features different from SOAP::Lite
SOAP::WSDL does not aim to be a complete replacement for SOAP::Lite - the
@@ -371,9 +360,9 @@ Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
=head1 REPOSITORY INFORMATION
$Rev: 427 $
$Rev: 455 $
$LastChangedBy: kutterma $
$Id: Client.pm 427 2007-12-02 22:20:24Z kutterma $
$Id: Client.pm 455 2007-12-14 15:50:16Z kutterma $
$HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Client.pm $
=cut

View File

@@ -10,9 +10,16 @@ sub call {
my ($self, $method, $body, $header) = @_;
if (not blessed $body) {
$body = {} if not defined $body;
my $class = $method->{ body }->{ parts }->[0];
eval "require $class" || die $@;
$body = $class->new($body);
$body = ref $body eq 'ARRAY' ? $body : [ $body ];
my $index = 0;
my @part_from;
foreach my $part (@{ $body }) {
my $class = $method->{ body }->{ parts }->[$index];
eval "require $class" || die $@;
push @part_from, $class->new($part);
$index++;
}
$body = $#part_from ? \@part_from : $part_from[0];
}
# if we have a header
@@ -94,9 +101,9 @@ Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
=head1 REPOSITORY INFORMATION
$Rev: 427 $
$Rev: 440 $
$LastChangedBy: kutterma $
$Id: Base.pm 427 2007-12-02 22:20:24Z kutterma $
$Id: Base.pm 440 2007-12-04 22:24:33Z kutterma $
$HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Client/Base.pm $
=cut

View File

@@ -48,7 +48,7 @@ sub load_classes {
# a bad test - do you know a better one?
next if $class eq '__SKIP__';
next if defined @{ "$class\::ISA"}; # check if namespace exists
next if defined *{ "$class\::" }; # check if namespace exists
$class =~s{ :: }{/}xmsg;
$class .= '.pm';
@@ -289,8 +289,8 @@ This module may be used under the same terms as perl itself.
$ID: $
$LastChangedDate: 2007-12-02 23:20:24 +0100 (So, 02 Dez 2007) $
$LastChangedRevision: 427 $
$LastChangedDate: 2007-12-07 21:04:06 +0100 (Fr, 07 Dez 2007) $
$LastChangedRevision: 444 $
$LastChangedBy: kutterma $
$HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/MessageParser.pm $

View File

@@ -5,7 +5,7 @@ use Carp;
use SOAP::WSDL::TypeLookup;
use base qw(SOAP::WSDL::Expat::Base);
our $VERSION = q{2.00_25};
our $VERSION = q{2.00_27};
sub _initialize {
my ($self, $parser) = @_;
@@ -36,7 +36,9 @@ sub _initialize {
eval "require $action->{ class }";
croak $@ if ($@);
my $obj = $action->{ class }->new({ parent => $current })
my $obj = $action->{ class }->new({ parent => $current,
xmlns => { '#default' => $parser->namespace($localname) }
})
->init( _fixup_attrs( $parser, %attrs ) );
if ($current) {

View File

@@ -38,7 +38,7 @@ sub get_transport {
if ($registered_transport_of{ $scheme }) {
no strict qw(refs);
*{ $registered_transport_of{ $scheme } . '::' }{ CODE }
defined %{ "$registered_transport_of{ $scheme }::" }
or eval "require $registered_transport_of{ $scheme }"
or die "Cannot load transport class $registered_transport_of{ $scheme } : $@";
@@ -71,7 +71,7 @@ sub get_transport {
if (exists $SOAP_WSDL_TRANSPORT_OF{ $scheme }) {
no strict qw(refs);
*{ $SOAP_WSDL_TRANSPORT_OF{ $scheme } . '::' }{ CODE }
defined %{ "$SOAP_WSDL_TRANSPORT_OF{ $scheme }::" }
or eval "require $SOAP_WSDL_TRANSPORT_OF{ $scheme }"
or die "Cannot load transport class $SOAP_WSDL_TRANSPORT_OF{ $scheme } : $@";
return $SOAP_WSDL_TRANSPORT_OF{ $scheme }->new( %attrs );
@@ -240,9 +240,9 @@ Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
=head1 REPOSITORY INFORMATION
$Rev: 435 $
$Rev: 459 $
$LastChangedBy: kutterma $
$Id: Transport.pm 435 2007-12-03 22:31:00Z kutterma $
$Id: Transport.pm 459 2007-12-16 16:00:14Z kutterma $
$HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Factory/Transport.pm $
=cut

View File

@@ -55,9 +55,11 @@ sub generate {
}
sub generate_typelib {
my ($self) = @_;
my ($self, $arg_ref) = @_;
# $output_of{ ident $self } = "";
my @schema = @{ $self->get_definitions()->first_types()->get_schema() };
my @schema = exists $arg_ref->{ schema }
? @{ $arg_ref->{schema} }
: @{ $self->get_definitions()->first_types()->get_schema() };
for my $type (map { @{ $_->get_type() } , @{ $_->get_element() } } @schema[1..$#schema] ) {
$type->_accept( $self );
}
@@ -164,6 +166,7 @@ sub _generate_filename :PRIVATE {
my ($self, @parts) = @_;
my $name = join '::', @parts;
$name =~s{ \. }{::}xmsg;
$name =~s{ \- }{_}xmsg;
$name =~s{ :: }{/}xmsg;
return "$name.pm";
}

View File

@@ -1,4 +1,4 @@
package [% interface_prefix %]::[% service.get_name.replace('\.', '::') %]::[% port.get_name.replace('^.+\.','') %];
package [% interface_prefix %]::[% service.get_name.replace('\.', '::').replace('-', '_') %]::[% port.get_name.replace('^.+\.','').replace('-', '_') %];
use strict;
use warnings;
use Class::Std::Fast::Storable;
@@ -6,12 +6,12 @@ use Scalar::Util qw(blessed);
use base qw(SOAP::WSDL::Client::Base);
# only load if it hasn't been loaded before
require [% typemap_prefix %]::[% service.get_name.replace('\.', '::') %]
if not [% typemap_prefix %]::[% service.get_name.replace('\.', '::') %]->can('get_class');
require [% typemap_prefix %]::[% service.get_name.replace('\.', '::').replace('-', '_') %]
if not [% typemap_prefix %]::[% service.get_name.replace('\.', '::').replace('-', '_') %]->can('get_class');
sub START {
$_[0]->set_proxy('[% port.first_address.get_location %]') if not $_[2]->{proxy};
$_[0]->set_class_resolver('[% typemap_prefix %]::[% service.get_name.replace('\.', '::') %]')
$_[0]->set_class_resolver('[% typemap_prefix %]::[% service.get_name.replace('\.', '::').replace('-', '_') %]')
if not $_[2]->{class_resolver};
}
@@ -34,12 +34,12 @@ __END__
=head1 NAME
[% interface_prefix %]::[% service.get_name.replace('\.', '::') %]::[% port.get_name.replace('\.', '::') %] - SOAP Interface for the [% service.get_name %] Web Service
[% interface_prefix %]::[% service.get_name.replace('\.', '::').replace('-', '_') %]::[% port.get_name.replace('\.', '::').replace('-', '_') %] - SOAP Interface for the [% service.get_name %] Web Service
=head1 SYNOPSIS
use [% interface_prefix %]::[% service.get_name.replace('\.', '::') %]::[% port.get_name.replace('\.', '::') %];
my $interface = [% interface_prefix %]::[% service.get_name.replace('\.', '::') %]::[% port.get_name.replace('\.', '::') %]->new();
use [% interface_prefix %]::[% service.get_name.replace('\.', '::').replace('-', '_') %]::[% port.get_name.replace('\.', '::').replace('-', '_') %];
my $interface = [% interface_prefix %]::[% service.get_name.replace('\.', '::').replace('-', '_') %]::[% port.get_name.replace('\.', '::').replace('-', '_') %]->new();
my $response;
[% FOREACH operation = binding.get_operation;

View File

@@ -55,6 +55,11 @@
: die "input must have either type or element";
} @{ $part_from };
}
warn "Multiple parts detected in message " . $stash->{ message }->get_name() . ".\n",
"WS-I BP demands 0 to 1 parts in message body\n"
if (@parts > 1);
$stash->{ parts } = \@parts;
[% END %]

View File

@@ -22,7 +22,7 @@ __END__
=head1 NAME
[% typemap_prefix %]::[% service.get_name.replace('\.','::') %]; - typemap for ::[% service.get_name %];
[% typemap_prefix %]::[% service.get_name.replace('\.','::').replace('-', '_') %]; - typemap for ::[% service.get_name %];
=head1 DESCRIPTION

View File

@@ -1,4 +1,4 @@
package [% type_prefix %]::[% complexType.get_name %];
package [% type_prefix %]::[% complexType.get_name.replace('\.','::').replace('-','_') %];
use strict;
use warnings;
[% INCLUDE complexType/contentModel.tt %]
@@ -12,7 +12,7 @@ use warnings;
=head1 NAME
[% type_prefix %]::[% complexType.get_name %]
[% type_prefix %]::[% complexType.get_name.replace('\.','::').replace('-','_') %]
=head1 DESCRIPTION

View File

@@ -1,6 +1,6 @@
[%
base_name=complexType.expand( complexType.get_base);
base_name=complexType.expand( complexType.get_base );
base_type = definitions.first_types.find_type( base_name );
element_from = complexType.get_element;
@@ -9,14 +9,15 @@ element_from = complexType.get_element;
# Sanity check: All original elements must be noted first
#
element_list = base_type.get_element;
FOREACH element = base_type.get_element;
IF element_from.${ loop.index }.get_name != element.get_name;
# element_list.push( element );
THROW WSDL "${element.get_name} not found at position ${ loop.index } in extension type ${ complexType.get_name }";
FOREACH element = element_from;
IF element_list.${ loop.index }.get_name != element.get_name;
element_list.push( element );
# THROW WSDL "${element.get_name} not found at position ${ loop.index } in extension type ${ complexType.get_name }";
END;
END;
#complexType.set_element( element_list );
complexType.set_element( element_list );
-%]
use base qw([% type_prefix %]::[% base_name.1.replace('\.', '::') %]);

View File

@@ -1,4 +1,4 @@
package [% element_prefix %]::[% element.get_name %];
package [% element_prefix %]::[% element.get_name.replace('\.','::') %];
use strict;
use warnings;

View File

@@ -1,4 +1,4 @@
package [% type_prefix %]::[% simpleType.get_name %];
package [% type_prefix %]::[% simpleType.get_name.replace('\.','::').replace('-','_') %];
use strict;
use warnings;
@@ -13,7 +13,7 @@ sub get_xmlns { '[% simpleType.get_targetNamespace %]'};
=pod
=head1 [% type_prefix %]::[% simpleType.get_name %]
=head1 [% type_prefix %]::[% simpleType.get_name.replace('\.','::').replace('-','_') %]
=head1 DESCRIPTION

View File

@@ -211,6 +211,8 @@ sub visit_XSD_Element {
# for atomic and complex types , and ref elements
my $typeclass = join q{::}, $element_prefix_of{$ident}, $element->get_name();
$typeclass =~s{\.}{::}g;
$typeclass =~s{\-}{_}g;
$self->set_typemap_entry($typeclass);
$self->process_atomic_type( $element->first_complexType()
@@ -225,6 +227,8 @@ sub visit_XSD_Element {
if (not defined($parent)) {
# for atomic and complex types , and ref elements
my $typeclass = join q{::}, $element_prefix_of{$ident}, $element->get_name();
$typeclass =~s{\.}{::}g;
$typeclass =~s{\-}{_}g;
$self->set_typemap_entry($typeclass);
}

View File

@@ -12,7 +12,7 @@ SOAP::WSDL::Manual - Accessing WSDL based web services
=item * Create WSDL bindings
perl wsdl2perl.pl -b base_dir URL
perl wsdl2perl.pl -b base_dir URL
=item * Look what has been generated
@@ -37,7 +37,7 @@ The results of all calls to your service object's methods (except new) are
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 @@ and you may even want to add custom typemap elements.
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 @@ included perldoc will be, too - if not, blame the web service author.
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<SOAP::WSDL::SOAP::Typelib::Fault11|SOAP::WSDL::SOAP::Typelib::Fault11>
objects SOAP::WSDL uses for signalling failure.
@@ -144,12 +144,12 @@ generated classes - while generated classes may be many, you probably will
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.
@@ -230,6 +230,17 @@ L<SOAP::WSDL::Manual::Parser> will tell you how to create a typemap class.
=back
=head1 Creating a SOAP Server
Creating a SOAP server works just like creating a client - just add the
C<--server> or C<-s> option to the call to C<wsdl2perl.pl>.
perl wsdl2perl.pl -s -b BASE_DIR URL
Note that SOAP::WSDL only includes a basic CGI based SOAP servers by now -
while more advanced servers (like standalone or mod_perl based) are no big
deal, no base implementation is included yet.
=head1 Troubleshooting
=head2 Accessing HTTPS webservices

View File

@@ -3,7 +3,7 @@ package SOAP::WSDL::Serializer::XSD;
use strict;
use warnings;
use Class::Std::Fast::Storable;
use Scalar::Util qw(blessed);
our $VERSION=q{2.00_25};
my $SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/';
@@ -49,7 +49,7 @@ sub serialize_header {
return q{} if not $data;
return join ( q{},
"<$opt->{ namespace }->{ $SOAP_NS }\:Header>",
"$data",
blessed $data ? $data->serialize_qualified : (),
"</$opt->{ namespace }->{ $SOAP_NS }\:Header>",
);
}
@@ -61,7 +61,13 @@ sub serialize_body {
# if we have no data.
return join ( q{},
"<$opt->{ namespace }->{ $SOAP_NS }\:Body>",
defined $data ? "$data" : (),
defined $data
? ref $data eq 'ARRAY'
? join q{}, map { blessed $_ ? $_->serialize_qualified() : () } @{ $data }
: blessed $data
? $data->serialize_qualified
: ()
: (),
"</$opt->{ namespace }->{ $SOAP_NS }\:Body>",
);
}
@@ -113,9 +119,9 @@ Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
=head1 REPOSITORY INFORMATION
$Rev: 427 $
$Rev: 444 $
$LastChangedBy: kutterma $
$Id: XSD.pm 427 2007-12-02 22:20:24Z kutterma $
$Id: XSD.pm 444 2007-12-07 20:04:06Z kutterma $
$HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Serializer/XSD.pm $
=cut

View File

@@ -7,9 +7,12 @@ sub get_xmlns { 'http://www.w3.org/2001/XMLSchema' };
# use $_[1] for performance
sub start_tag {
my $opt = $_[1] ||= {};
return '<' . $opt->{name} . ' >' if $opt->{ name };
return q{}
return q{} if not $#_; # return if no second argument ($opt)
if ($_[1]->{ name }) {
return "<$_[1]->{name} />" if $_[1]->{ empty };
return "<$_[1]->{name} >";
}
return q{};
}
# use $_[1] for performance

View File

@@ -39,6 +39,34 @@ sub AUTOMETHOD {
. "\n"
}
sub as_hash_ref {
my $self = shift;
my $attributes_ref = $ATTRIBUTES_OF{ ref $self };
my $ident = ident $self;
my $hash_of_ref = {};
foreach my $attribute (keys %{ $attributes_ref }) {
next if not defined $attributes_ref->{ $attribute }->{ $ident };
my $value = $attributes_ref->{ $attribute }->{ $ident };
$hash_of_ref->{ $attribute } = blessed $value
? $value->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType')
? $value
: $value->as_hash_ref()
: ref $value eq 'ARRAY'
? [
map {
$_->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType')
? $_
: $_->as_hash_ref()
} @{ $value }
]
: die "Neither blessed obj nor list ref";
};
return $hash_of_ref;
}
# we store per-class elements.
# call as __PACKAGE__->_factory
sub _factory {
@@ -352,6 +380,10 @@ This means you may set element properties by passing
Examples are similar to the examples provided for new() above.
=head2 as_hash_ref
Returns a hash ref representation of the complexType object
=head1 Bugs and limitations
=over
@@ -391,9 +423,9 @@ Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
=head1 REPOSITORY INFORMATION
$Rev: 412 $
$Rev: 452 $
$LastChangedBy: kutterma $
$Id: ComplexType.pm 412 2007-11-27 22:57:52Z kutterma $
$Id: ComplexType.pm 452 2007-12-12 14:46:54Z kutterma $
$HeadURL: http://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm $
=cut