import SOAP-WSDL 2.00_24 from CPAN
git-cpan-module: SOAP-WSDL git-cpan-version: 2.00_24 git-cpan-authorid: MKUTTER git-cpan-file: authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_24.tar.gz
This commit is contained in:
committed by
Michael G. Schwern
parent
b955c5ad79
commit
84b53d9261
@@ -23,15 +23,15 @@ sub START {
|
||||
sub _process :PROTECTED {
|
||||
my ($self, $template, $arg_ref, $output) = @_;
|
||||
my $ident = ident $self;
|
||||
my $tt = $tt_of{$ident} ||= Template->new(
|
||||
my $tt = $tt_of{$ident} ||= Template->new(
|
||||
DEBUG => 1,
|
||||
EVAL_PERL => $EVAL_PERL_of{ $ident },
|
||||
RECURSION => $RECURSION_of{ $ident },
|
||||
INCLUDE_PATH => $INCLUDE_PATH_of{ $ident },
|
||||
OUTPUT_PATH => $OUTPUT_PATH_of{ $ident },
|
||||
);
|
||||
$tt->process( $template,
|
||||
{
|
||||
$tt->process( $template,
|
||||
{
|
||||
definitions => $self->get_definitions,
|
||||
interface_prefix => $self->get_interface_prefix,
|
||||
type_prefix => $self->get_type_prefix,
|
||||
@@ -40,10 +40,9 @@ sub _process :PROTECTED {
|
||||
element_prefix => $self->get_element_prefix,
|
||||
NO_POD => delete $arg_ref->{ NO_POD } ? 1 : 0 ,
|
||||
%{ $arg_ref }
|
||||
},
|
||||
},
|
||||
$output)
|
||||
or die $INCLUDE_PATH_of{ $ident }, '\\', $template, ' ', $tt->error();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -18,23 +18,23 @@ sub BUILD {
|
||||
$self->set_RECURSION(1);
|
||||
$self->set_INCLUDE_PATH( exists $arg_ref->{INCLUDE_PATH}
|
||||
? $arg_ref->{INCLUDE_PATH}
|
||||
: do {
|
||||
# ignore uninitialized warnings - File::Spec warns about
|
||||
: do {
|
||||
# ignore uninitialized warnings - File::Spec warns about
|
||||
# uninitialized values, probably because we have no filename
|
||||
local $SIG{__WARN__} = sub {
|
||||
return if ($_[0]=~m{\buninitialized\b});
|
||||
CORE::warn @_;
|
||||
};
|
||||
|
||||
|
||||
# makeup path for the OS we're running on
|
||||
my ($volume, $dir, $file) = File::Spec->splitpath(
|
||||
my ($volume, $dir, $file) = File::Spec->splitpath(
|
||||
File::Spec->rel2abs( dirname __FILE__ )
|
||||
);
|
||||
$dir = File::Spec->catdir($dir, $file, 'XSD');
|
||||
# return path put together...
|
||||
my $path = File::Spec->catpath( $volume, $dir );
|
||||
|
||||
# Fixup path for windows - / works fine, \ does
|
||||
|
||||
# Fixup path for windows - / works fine, \ does
|
||||
# not...
|
||||
if ( eval { &Win32::BuildNumber } ) {
|
||||
$path =~s{\\}{/}g;
|
||||
@@ -54,16 +54,13 @@ sub generate {
|
||||
|
||||
sub generate_typelib {
|
||||
my ($self) = @_;
|
||||
|
||||
# $output_of{ ident $self } = "";
|
||||
|
||||
my @schema = @{ $self->get_definitions()->first_types()->get_schema() };
|
||||
for my $type (map { @{ $_->get_type() } , @{ $_->get_element() } } @schema[1..$#schema] ) {
|
||||
$type->_accept( $self );
|
||||
}
|
||||
|
||||
# return $output_of{ ident $self };
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub generate_interface {
|
||||
@@ -72,23 +69,23 @@ sub generate_interface {
|
||||
my $arg_ref = shift;
|
||||
my $tt = $self->get_tt();
|
||||
for my $service (@{ $self->get_definitions->get_service }) {
|
||||
for my $port (@{ $service->get_port() }) {
|
||||
for my $port (@{ $service->get_port() }) {
|
||||
# Skip ports without (known) address
|
||||
next if not $port->first_address;
|
||||
next if not $port->first_address->isa('SOAP::WSDL::SOAP::Address');
|
||||
|
||||
my $port_name = $port->get_name;
|
||||
$port_name =~s{ \A .+\. }{}xms;
|
||||
my $output = $arg_ref->{ output }
|
||||
? $arg_ref->{ output }
|
||||
: $self->_generate_filename(
|
||||
$self->get_interface_prefix(),
|
||||
$service->get_name(),
|
||||
my $output = $arg_ref->{ output }
|
||||
? $arg_ref->{ output }
|
||||
: $self->_generate_filename(
|
||||
$self->get_interface_prefix(),
|
||||
$service->get_name(),
|
||||
$port_name,
|
||||
);
|
||||
);
|
||||
print "Creating interface class $output\n";
|
||||
|
||||
$self->_process('Interface.tt',
|
||||
|
||||
$self->_process('Interface.tt',
|
||||
{
|
||||
service => $service,
|
||||
port => $port,
|
||||
@@ -101,7 +98,6 @@ sub generate_interface {
|
||||
|
||||
sub generate_typemap {
|
||||
my ($self, $arg_ref) = @_;
|
||||
|
||||
my $visitor = SOAP::WSDL::Generator::Visitor::Typemap->new({
|
||||
type_prefix => $self->get_type_prefix(),
|
||||
element_prefix => $self->get_element_prefix(),
|
||||
@@ -112,17 +108,16 @@ sub generate_typemap {
|
||||
'Fault/faultactor' => 'SOAP::WSDL::XSD::Typelib::Builtin::TOKEN',
|
||||
'Fault/faultstring' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
'Fault/detail' => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
%{ $typemap_of{ident $self }},
|
||||
%{ $typemap_of{ident $self }},
|
||||
}
|
||||
});
|
||||
for my $service (@{ $self->get_definitions->get_service }) {
|
||||
$visitor->visit_Service( $service );
|
||||
my $output = $arg_ref->{ output }
|
||||
? $arg_ref->{ output }
|
||||
: $self->_generate_filename( $self->get_typemap_prefix(), $service->get_name() );
|
||||
|
||||
my $output = $arg_ref->{ output }
|
||||
? $arg_ref->{ output }
|
||||
: $self->_generate_filename( $self->get_typemap_prefix(), $service->get_name() );
|
||||
print "Creating typemap class $output\n";
|
||||
$self->_process('Typemap.tt',
|
||||
$self->_process('Typemap.tt',
|
||||
{
|
||||
service => $service,
|
||||
typemap => $visitor->get_typemap(),
|
||||
@@ -142,7 +137,7 @@ sub _generate_filename :PRIVATE {
|
||||
|
||||
sub visit_XSD_Element {
|
||||
my ($self, $element) = @_;
|
||||
my $output = defined $output_of{ ident $self }
|
||||
my $output = defined $output_of{ ident $self }
|
||||
? $output_of{ ident $self }
|
||||
: $self->_generate_filename( $self->get_element_prefix(), $element->get_name() );
|
||||
$self->_process('element.tt', { element => $element } , $output);
|
||||
@@ -150,7 +145,7 @@ sub visit_XSD_Element {
|
||||
|
||||
sub visit_XSD_SimpleType {
|
||||
my ($self, $type) = @_;
|
||||
my $output = defined $output_of{ ident $self }
|
||||
my $output = defined $output_of{ ident $self }
|
||||
? $output_of{ ident $self }
|
||||
: $self->_generate_filename( $self->get_type_prefix(), $type->get_name() );
|
||||
$self->_process('simpleType.tt', { simpleType => $type } , $output);
|
||||
@@ -158,7 +153,7 @@ sub visit_XSD_SimpleType {
|
||||
|
||||
sub visit_XSD_ComplexType {
|
||||
my ($self, $type) = @_;
|
||||
my $output = defined $output_of{ ident $self }
|
||||
my $output = defined $output_of{ ident $self }
|
||||
? $output_of{ ident $self }
|
||||
: $self->_generate_filename( $self->get_type_prefix(), $type->get_name() );
|
||||
$self->_process('complexType.tt', { complexType => $type } , $output);
|
||||
|
||||
@@ -2,11 +2,12 @@ package [% interface_prefix %]::[% service.get_name.replace('\.', '::') %]::[% p
|
||||
use strict;
|
||||
use warnings;
|
||||
use Class::Std::Storable;
|
||||
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');
|
||||
if not [% typemap_prefix %]::[% service.get_name.replace('\.', '::') %]->can('get_class');
|
||||
|
||||
sub START {
|
||||
$_[0]->set_proxy('[% port.first_address.get_location %]') if not $_[2]->{proxy};
|
||||
@@ -18,6 +19,7 @@ sub START {
|
||||
FOREACH operation = binding.get_operation;
|
||||
%][% INCLUDE Interface/Operation.tt %]
|
||||
[%
|
||||
|
||||
END;
|
||||
%]
|
||||
|
||||
@@ -32,11 +34,22 @@ __END__
|
||||
=head1 NAME
|
||||
|
||||
|
||||
[% interface_prefix %]::[% service.get_name %]::[% port.get_name %] - SOAP Interface for the [% service.get_name %] Web Service
|
||||
[% interface_prefix %]::[% service.get_name.replace('\.', '::') %]::[% port.get_name.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();
|
||||
|
||||
my $response;
|
||||
[% FOREACH operation = binding.get_operation;
|
||||
%] $response = $interface->[% operation.get_name %]();
|
||||
[% END %]
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SOAP Interface for the [% service.get_name %] web service
|
||||
SOAP Interface for the [% service.get_name %] web service
|
||||
located at [% port.first_address.get_location %].
|
||||
|
||||
=head1 SERVICE [% service.get_name %]
|
||||
@@ -64,7 +77,7 @@ All arguments are forwarded to L<SOAP::WSDL::Client|SOAP::WSDL::Client>.
|
||||
|
||||
[% FOREACH operation = binding.get_operation;
|
||||
%][% INCLUDE Interface/POD/Operation.tt %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
|
||||
@@ -11,54 +11,53 @@
|
||||
my $element_prefix = $stash->{ element_prefix };
|
||||
|
||||
my @body_part_from = split m{\s}, $item->get_parts;
|
||||
|
||||
my @parts;
|
||||
if (@body_part_from) {
|
||||
@parts = map {
|
||||
my $part = $_;
|
||||
(grep {
|
||||
my ($ns, $lname) = $def->expand( $_ );
|
||||
($lname eq $part->get_name)
|
||||
} @body_part_from
|
||||
)
|
||||
? do {
|
||||
my $name;
|
||||
($name = $part->get_element)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
$element_prefix . '::' . $name;
|
||||
}
|
||||
: ($name = $part->get_type)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
$type_prefix . '::' . $name;
|
||||
}
|
||||
: die "input must have either type or element"
|
||||
}
|
||||
: ()
|
||||
} @{ $part_from };
|
||||
}
|
||||
else {
|
||||
@parts = map {
|
||||
my $part = $_;
|
||||
my $name;
|
||||
($name = $part->get_element)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
"$element_prefix\::$name"
|
||||
}
|
||||
: ($name = $part->get_type)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
"$type_prefix\::$name"
|
||||
}
|
||||
: die "input must have either type or element";
|
||||
} @{ $part_from };
|
||||
|
||||
my @parts;
|
||||
if (@body_part_from) {
|
||||
@parts = map {
|
||||
my $part = $_;
|
||||
(grep {
|
||||
my ($ns, $lname) = $def->expand( $_ );
|
||||
($lname eq $part->get_name)
|
||||
} @body_part_from
|
||||
)
|
||||
? do {
|
||||
my $name;
|
||||
($name = $part->get_element)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
$element_prefix . '::' . $name;
|
||||
}
|
||||
: ($name = $part->get_type)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
$type_prefix . '::' . $name;
|
||||
}
|
||||
: die "input must have either type or element"
|
||||
}
|
||||
: ()
|
||||
} @{ $part_from };
|
||||
}
|
||||
else {
|
||||
@parts = map {
|
||||
my $part = $_;
|
||||
my $name;
|
||||
($name = $part->get_element)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
"$element_prefix\::$name"
|
||||
}
|
||||
: ($name = $part->get_type)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
"$type_prefix\::$name"
|
||||
}
|
||||
: die "input must have either type or element";
|
||||
} @{ $part_from };
|
||||
}
|
||||
$stash->{ parts } = \@parts;
|
||||
|
||||
[% END;
|
||||
%]
|
||||
|
||||
[% END %]
|
||||
'use' => '[% item.get_use %]',
|
||||
namespace => '[% item.get_namespace %]',
|
||||
encodingStyle => '[% item.get_encodingStyle %]',
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[%
|
||||
RETURN IF NOT item;
|
||||
message_name = item.get_message;
|
||||
IF NOT message_name;
|
||||
THROW BAD_WSDL "missing <message> attribute in header for operation ${operation.get_name}";
|
||||
IF NOT message_name;
|
||||
THROW BAD_WSDL "missing <message> attribute in header for operation ${operation.get_name}";
|
||||
END;
|
||||
message = definitions.find_message( item.expand( message_name ) );
|
||||
PERL %]
|
||||
@@ -13,22 +13,22 @@
|
||||
my $element_prefix = $stash->{ element_prefix };
|
||||
my ($ns, $lname) = $def->expand( $item->get_part() );
|
||||
my ($part) = grep {
|
||||
$_->get_name eq $lname
|
||||
&& $_->get_targetNamespace eq $ns } @{ $message->get_part( ) };
|
||||
$_->get_name eq $lname
|
||||
&& $_->get_targetNamespace eq $ns } @{ $message->get_part( ) };
|
||||
my $part_class = do {
|
||||
my $name;
|
||||
($name = $part->get_element)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
$element_prefix . '::' . $name;
|
||||
}
|
||||
: ($name = $part->get_type)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
$type_prefix . '::' . $name;
|
||||
}
|
||||
: die "input must have either type or element"
|
||||
};
|
||||
my $name;
|
||||
($name = $part->get_element)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
$element_prefix . '::' . $name;
|
||||
}
|
||||
: ($name = $part->get_type)
|
||||
? do {
|
||||
$name =~s{ ^[^:]+: }{}xms;
|
||||
$type_prefix . '::' . $name;
|
||||
}
|
||||
: die "input must have either type or element"
|
||||
};
|
||||
$stash->{ part_class } = $part_class;
|
||||
[% END;
|
||||
%]
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
sub [% operation.get_name %] {
|
||||
my ($self, $body, $header) = @_;
|
||||
die "[% operation.get_name %] must be called as object method (\$self is <$self>)" if not blessed($self);
|
||||
return $self->SUPER::call({
|
||||
operation => '[% operation.get_name %]',
|
||||
operation => '[% operation.get_name %]',
|
||||
soap_action => '[% operation.first_operation.get_soapAction %]',
|
||||
style => '[% operation.get_style || binding.get_style %]',
|
||||
body => {
|
||||
body => {
|
||||
[% INCLUDE Interface/Body.tt( item = operation.first_input.first_body ); %]
|
||||
},
|
||||
header => {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
[% INDENT; %][% element.get_name %] => [%-
|
||||
IF (element.get_ref);
|
||||
element = element.get_ref();
|
||||
END;
|
||||
IF (type_name = element.get_type);
|
||||
IF (element.get_ref);
|
||||
element = element.get_ref();
|
||||
END;
|
||||
IF (type_name = element.get_type);
|
||||
INCLUDE Interface/POD/Type.tt(type = definitions.first_types.find_type( element.expand(type_name) ) );
|
||||
ELSIF (type = element.first_complexType);
|
||||
INCLUDE Interface/POD/Type.tt(type = type );
|
||||
ELSIF (type = element.first_simpleType);
|
||||
INCLUDE Interface/POD/Type.tt(type = type );
|
||||
END;
|
||||
END;
|
||||
%]
|
||||
@@ -1,9 +1,9 @@
|
||||
[%
|
||||
message_name = port_op.first_input.get_message();
|
||||
# message_name;
|
||||
# message_name;
|
||||
|
||||
part_from = definitions.find_message( port_op.first_input.expand( message_name ) ).get_part;
|
||||
FOREACH part = part_from;
|
||||
INCLUDE Interface/POD/Part.tt(part = part);
|
||||
INCLUDE Interface/POD/Part.tt(part = part);
|
||||
END;
|
||||
%]
|
||||
@@ -1,7 +1,7 @@
|
||||
[% element = definitions.first_types.find_element( part.expand( part.get_element ) );
|
||||
#element.get_name();
|
||||
#element;
|
||||
#STOP;
|
||||
type = element.first_complexType || element.first_simpleType || definitions.first_types.find_type(
|
||||
element.expand( element.get_type ) );
|
||||
INCLUDE Interface/POD/Type.tt;%],
|
||||
#element.get_name();
|
||||
#element;
|
||||
#STOP;
|
||||
type = element.first_complexType || element.first_simpleType || definitions.first_types.find_type(
|
||||
element.expand( element.get_type ) );
|
||||
INCLUDE Interface/POD/Type.tt;%],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[%- indent = ' ';
|
||||
IF type.isa('SOAP::WSDL::XSD::ComplexType');
|
||||
INCLUDE complexType/POD/structure.tt(complexType = type);
|
||||
INCLUDE complexType/POD/structure.tt(complexType = type);
|
||||
ELSE;
|
||||
INCLUDE simpleType/POD/structure.tt(simpleType = type);
|
||||
INCLUDE simpleType/POD/structure.tt(simpleType = type);
|
||||
END;
|
||||
indent.replace('\s{2}$',''); %]
|
||||
@@ -1,7 +1,7 @@
|
||||
Method synopsis is displayed with hash refs as parameters.
|
||||
Method synopsis is displayed with hash refs as parameters.
|
||||
|
||||
The commented class names in the method's parameters denote that objects
|
||||
The commented class names in the method's parameters denote that objects
|
||||
of the corresponding class can be passed instead of the marked hash ref.
|
||||
|
||||
You may pass any combination of objects, hash and list refs to these
|
||||
You may pass any combination of objects, hash and list refs to these
|
||||
methods, as long as you meet the structure.
|
||||
|
||||
@@ -4,7 +4,7 @@ use warnings;
|
||||
|
||||
our [% USE Dumper(varname = 'typemap_'); Dumper.dump( typemap ) %];
|
||||
|
||||
sub get_class {
|
||||
sub get_class {
|
||||
my $name = join '/', @{ $_[1] };
|
||||
exists $typemap_1->{ $name } or die "Cannot resolve $name via " . __PACKAGE__;
|
||||
return $typemap_1->{ $name };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[% type_name = node.expand( type );
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
[% type_name = node.expand( type );
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
SOAP::WSDL::XSD::Typelib::Builtin::[% type_name.1 %]
|
||||
[% ELSE -%]
|
||||
[% type_prefix %]::[% type_name.1 %]
|
||||
[% END -%]
|
||||
[% ELSE -%]
|
||||
[% type_prefix %]::[% type_name.1 %]
|
||||
[% END -%]
|
||||
@@ -2,8 +2,8 @@ package [% type_prefix %]::[% complexType.get_name %];
|
||||
use strict;
|
||||
use warnings;
|
||||
[% INCLUDE complexType/contentModel.tt %]
|
||||
[%#
|
||||
# Don't include any perl source here - there may be sub-packages...
|
||||
[%#
|
||||
# Don't include any perl source here - there may be sub-packages...
|
||||
#-%]
|
||||
|
||||
1;
|
||||
@@ -21,7 +21,7 @@ Perl data type class for the XML Schema defined complextype
|
||||
|
||||
=head2 PROPERTIES
|
||||
|
||||
The following properties may be accessed using get_PROPERTY / set_PROPERTY
|
||||
The following properties may be accessed using get_PROPERTY / set_PROPERTY
|
||||
methods:
|
||||
|
||||
[% FOREACH element = complexType.get_element -%]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[% IF (complexType.get_variety == 'restriction');
|
||||
INCLUDE complexType/POD/restriction.tt(complexType = complexType);
|
||||
INCLUDE complexType/POD/restriction.tt(complexType = complexType);
|
||||
ELSIF (complexType.get_variety == 'sequence');
|
||||
THROW NOT_IMPLEMENTED, "${ complexType.get_name } - complexType complexContent extension not implemented yet";
|
||||
THROW NOT_IMPLEMENTED, "${ complexType.get_name } - complexType complexContent extension not implemented yet";
|
||||
ELSE;
|
||||
THROW UNKNOWN, "unknown variety ${ complexType.get_variety }";
|
||||
THROW UNKNOWN, "unknown variety ${ complexType.get_variety }";
|
||||
END;
|
||||
|
||||
%]
|
||||
@@ -1,13 +1,13 @@
|
||||
[% IF (complexType.get_variety == 'all');
|
||||
INCLUDE complexType/POD/all.tt(complexType = complexType);
|
||||
INCLUDE complexType/POD/all.tt(complexType = complexType);
|
||||
ELSIF (complexType.get_variety == 'sequence');
|
||||
INCLUDE complexType/POD/all.tt(complexType = complexType);
|
||||
INCLUDE complexType/POD/all.tt(complexType = complexType);
|
||||
ELSIF (complexType.get_variety == 'group');
|
||||
THROW NOT_IMPLEMENTED, "${ element.get_name } - complexType group not implemented yet";
|
||||
THROW NOT_IMPLEMENTED, "${ element.get_name } - complexType group not implemented yet";
|
||||
ELSIF (complexType.get_variety == 'choice');
|
||||
INCLUDE complexType/POD/choice.tt(complexType = complexType);
|
||||
INCLUDE complexType/POD/choice.tt(complexType = complexType);
|
||||
ELSIF (complexType.get_contentModel == 'simpleContent');
|
||||
THROW NOT_IMPLEMENTED, "${ element.get_name } - complexType simpleContent not implemented yet";
|
||||
THROW NOT_IMPLEMENTED, "${ element.get_name } - complexType simpleContent not implemented yet";
|
||||
ELSIF (complexType.get_contentModel == 'complexContent');
|
||||
INCLUDE complexType/POD/complexContent.tt(complexType = complexType);
|
||||
END %]
|
||||
INCLUDE complexType/POD/complexContent.tt(complexType = complexType);
|
||||
END %],
|
||||
@@ -2,8 +2,8 @@ use Class::Std::Storable;
|
||||
use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
|
||||
|
||||
{ # BLOCK to scope variables
|
||||
[%
|
||||
atomic_types = [];
|
||||
[%
|
||||
atomic_types = {};
|
||||
|
||||
FOREACH element = complexType.get_element %]
|
||||
my %[% element.get_name %]_of :ATTR(:get<[% element.get_name %]>);
|
||||
@@ -14,30 +14,30 @@ __PACKAGE__->_factory(
|
||||
[% element.get_name -%]
|
||||
[% END %]
|
||||
) ],
|
||||
{
|
||||
{
|
||||
[% FOREACH element = complexType.get_element -%]
|
||||
[% element.get_name %] => \%[% element.get_name %]_of,
|
||||
[% END -%]
|
||||
[% element.get_name %] => \%[% element.get_name %]_of,
|
||||
[% END -%]
|
||||
},
|
||||
{
|
||||
[% FOREACH element = complexType.get_element;
|
||||
IF (type = element.get_type);
|
||||
element_type = complexType.expand( type );
|
||||
IF (element_type.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
IF (type = element.get_type);
|
||||
element_type = complexType.expand( type );
|
||||
IF (element_type.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
[% element.get_name %] => 'SOAP::WSDL::XSD::Typelib::Builtin::[% element_type.1 %]',
|
||||
[% ELSE -%]
|
||||
[% ELSE -%]
|
||||
[% element.get_name %] => '[% type_prefix %]::[% element_type.1 %]',
|
||||
[% END;
|
||||
ELSE;
|
||||
IF (element.first_simpleType);
|
||||
atomic_types.push( element.first_simpleType );
|
||||
ELSIF (element.first_simpleType);
|
||||
atomic_types.push( element.first_simpleType );
|
||||
ELSE;
|
||||
THROW NOT_IMPLEMENTED , "atomic types in complexType elements not supported yet";
|
||||
END; %]
|
||||
[% element.get_name %] => '[% type_prefix %]::[% complexType.get_name %]::_[% element.get_name %]',
|
||||
[% END;
|
||||
[% END;
|
||||
ELSE;
|
||||
IF (element.first_simpleType);
|
||||
atomic_types.${ element.get_name } = element.first_simpleType;
|
||||
ELSIF (element.first_complexType);
|
||||
atomic_types.${ element.get_name } = element.first_complexType;
|
||||
ELSE;
|
||||
THROW NOT_IMPLEMENTED , "Neither simple nor complex atomic type - don't know what to do with it";
|
||||
END; %]
|
||||
[% element.get_name %] => '[% type_prefix %]::[% complexType.get_name %]::_[% element.get_name %]',
|
||||
[% END;
|
||||
END -%]
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
|
||||
[% FOREACH type = atomic_types; %]
|
||||
[% FOREACH type IN atomic_types; %]
|
||||
|
||||
package [% type_prefix %]::[% complexType.get_name %]::_[% element.get_name %];
|
||||
package [% type_prefix %]::[% complexType.get_name %]::_[% type.key %];
|
||||
use strict;
|
||||
use warnings;
|
||||
{
|
||||
[% IF ( type.isa('SOAP::WSDL::XSD::ComplexType') );
|
||||
INCLUDE complexType/contentModel.tt(complexType = type );
|
||||
ELSIF ( type.isa('SOAP::WSDL::XSD::SimpleType') );
|
||||
INCLUDE simpleType/contentModel.tt(simpleType = type );
|
||||
ELSE;
|
||||
PERL; %] die $stash->{ type }->_DUMP [% END;
|
||||
THROW UNKNOWN, "neither complex nor simple type - don't know what to do";
|
||||
[% IF ( type.value.isa('SOAP::WSDL::XSD::ComplexType') );
|
||||
INCLUDE complexType/contentModel.tt(complexType = type.value );
|
||||
ELSIF ( type.value.isa('SOAP::WSDL::XSD::SimpleType') );
|
||||
INCLUDE simpleType/contentModel.tt(simpleType = type.value );
|
||||
ELSE;
|
||||
PERL; %] die $stash->{ type } [% END;
|
||||
THROW UNKNOWN, "neither complex nor simple type - don't know what to do";
|
||||
END
|
||||
%]
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[% IF (complexType.get_variety == 'restriction');
|
||||
INCLUDE complexType/restriction.tt(complexType = complexType);
|
||||
INCLUDE complexType/restriction.tt(complexType = complexType);
|
||||
ELSIF (complexType.get_variety == 'sequence');
|
||||
INCLUDE complexType/extension.tt(complexType = complexType);
|
||||
INCLUDE complexType/extension.tt(complexType = complexType);
|
||||
ELSE;
|
||||
THROW UNKNOWN, "unknown variety ${ complexType.get_variety }";
|
||||
THROW UNKNOWN, "unknown variety ${ complexType.get_variety }";
|
||||
END;
|
||||
%]
|
||||
@@ -1,7 +1,7 @@
|
||||
[% IF (complexType.get_contentModel == 'simpleContent');
|
||||
THROW NOT_IMPLEMENTED, "${ element.get_name } - complexType simpleContent not implemented yet";
|
||||
THROW NOT_IMPLEMENTED, "${ element.get_name } - complexType simpleContent not implemented yet";
|
||||
ELSIF (complexType.get_contentModel == 'complexContent');
|
||||
INCLUDE complexType/complexContent.tt(complexType = complexType);
|
||||
INCLUDE complexType/complexContent.tt(complexType = complexType);
|
||||
ELSE;
|
||||
INCLUDE complexType/variety.tt(complexType = complexType);
|
||||
INCLUDE complexType/variety.tt(complexType = complexType);
|
||||
END %]
|
||||
|
||||
@@ -9,14 +9,14 @@ element_from = complexType.get_element;
|
||||
# Sanity check: All original elements must be noted first
|
||||
#
|
||||
FOREACH element = base_type.get_element;
|
||||
IF element_from.${ loop.index }.get_name != element.get_name;
|
||||
THROW WSDL "${element.get_name} not found at position ${ loop.index } in extension type ${ complexType.get_name }";
|
||||
END;
|
||||
IF element_from.${ loop.index }.get_name != element.get_name;
|
||||
THROW WSDL "${element.get_name} not found at position ${ loop.index } in extension type ${ complexType.get_name }";
|
||||
END;
|
||||
END;
|
||||
|
||||
|
||||
-%]
|
||||
use base qw([% type_prefix %]::[% base_name.1.replace('\.', '::') %]);
|
||||
use base qw([% type_prefix %]::[% base_name.1.replace('\.', '::') %]);
|
||||
[%
|
||||
|
||||
INCLUDE complexType/variety.tt(complexType = complexType);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[% IF (base=complexType.get_base);
|
||||
base_name=complexType.expand(base);
|
||||
base_name=complexType.expand(base);
|
||||
-%]
|
||||
use base qw([% type_prefix %]::[% base_name.1.replace('\.', '::') %]);
|
||||
[%
|
||||
use base qw([% type_prefix %]::[% base_name.1.replace('\.', '::') %]);
|
||||
[%
|
||||
ELSE;
|
||||
THROW NOT_IMPLEMENTED, "restriction without base not supported";
|
||||
THROW NOT_IMPLEMENTED, "restriction without base not supported";
|
||||
END %]
|
||||
@@ -1,15 +1,15 @@
|
||||
[%
|
||||
IF (complexType.get_variety == 'all');
|
||||
INCLUDE complexType/all.tt(complexType = complexType);
|
||||
INCLUDE complexType/all.tt(complexType = complexType);
|
||||
ELSIF (complexType.get_variety == 'sequence');
|
||||
INCLUDE complexType/all.tt(complexType = complexType);
|
||||
INCLUDE complexType/all.tt(complexType = complexType);
|
||||
ELSIF (complexType.get_variety == 'group');
|
||||
THROW NOT_IMPLEMENTED, "${ element.get_name } - complexType group not implemented yet";
|
||||
THROW NOT_IMPLEMENTED, "${ element.get_name } - complexType group not implemented yet";
|
||||
ELSIF (complexType.get_variety == 'choice');
|
||||
INCLUDE complexType/all.tt(complexType = complexType);
|
||||
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 })";
|
||||
THROW NOT_IMPLEMENTED, "Unknown variety ${ complexType.get_variety } in ${ complexType.get_name } (${ element.get_name })";
|
||||
ELSE;
|
||||
# There's no variety - might be empty complexType
|
||||
# There's no variety - might be empty complexType
|
||||
END;
|
||||
%]
|
||||
@@ -14,26 +14,26 @@ __PACKAGE__->__set_ref([% IF element.get_ref; %]'[% element.get_ref %]'[% END %]
|
||||
|
||||
[%- IF (type = element.get_type); -%]
|
||||
use base qw(
|
||||
SOAP::WSDL::XSD::Typelib::Element
|
||||
[% INCLUDE _type_class.tt( type = type, node = element ) %]
|
||||
SOAP::WSDL::XSD::Typelib::Element
|
||||
[% INCLUDE _type_class.tt( type = type, node = element ) %]
|
||||
);
|
||||
[%- ELSIF (ref = element.get_ref); -%]
|
||||
# element ref="[% ref %]"
|
||||
use base qw(
|
||||
[% element_prefix %]::[% ref.split(':').1 %]
|
||||
[% element_prefix %]::[% ref.split(':').1 %]
|
||||
);
|
||||
[%- ELSIF (simpleType = element.first_simpleType) %]
|
||||
# atomic simpleType: <element><simpleType
|
||||
# atomic simpleType: <element><simpleType
|
||||
use base qw(
|
||||
SOAP::WSDL::XSD::Typelib::Element
|
||||
SOAP::WSDL::XSD::Typelib::Element
|
||||
);
|
||||
[% INCLUDE simpleType/contentModel.tt %]
|
||||
[% ELSIF (complexType = element.first_complexType) %]
|
||||
use base qw(
|
||||
SOAP::WSDL::XSD::Typelib::Element
|
||||
SOAP::WSDL::XSD::Typelib::ComplexType
|
||||
SOAP::WSDL::XSD::Typelib::Element
|
||||
SOAP::WSDL::XSD::Typelib::ComplexType
|
||||
);
|
||||
[% INCLUDE complexType/contentModel.tt;
|
||||
[% INCLUDE complexType/contentModel.tt;
|
||||
END %]
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
[%- IF (name = element.get_type);
|
||||
type_name = element.expand(name);
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
[%- IF (name = element.get_type);
|
||||
type_name = element.expand(name);
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
$some_value, # [% type_name.1 %]
|
||||
[%-
|
||||
RETURN;
|
||||
ELSIF (type = definitions.first_types.find_type( type_name ));
|
||||
IF (type.isa('SOAP::WSDL::XSD::ComplexType') );
|
||||
INCLUDE complexType/POD/structure.tt(complexType = type);
|
||||
RETURN;
|
||||
ELSE;
|
||||
INCLUDE simpleType/POD/structure.tt(simpleType = type);
|
||||
END;
|
||||
RETURN;
|
||||
END;
|
||||
THROW NOT_FOUND, "no type found for {${type_name.0}}${type_name.1}";
|
||||
[%-
|
||||
RETURN;
|
||||
ELSIF (type = definitions.first_types.find_type( type_name ));
|
||||
IF (type.isa('SOAP::WSDL::XSD::ComplexType') );
|
||||
INCLUDE complexType/POD/structure.tt(complexType = type);
|
||||
RETURN;
|
||||
ELSE;
|
||||
INCLUDE simpleType/POD/structure.tt(simpleType = type);
|
||||
END;
|
||||
RETURN;
|
||||
END;
|
||||
THROW NOT_FOUND, "no type found for {${type_name.0}}${type_name.1}";
|
||||
ELSIF (ref = element.get_ref);
|
||||
ref_element = definitions.first_types.find_element( element.expand( ref ) );
|
||||
INCLUDE element/POD/structure.tt(element = ref_element);
|
||||
RETURN;
|
||||
ref_element = definitions.first_types.find_element( element.expand( ref ) );
|
||||
INCLUDE element/POD/structure.tt(element = ref_element);
|
||||
RETURN;
|
||||
ELSIF (type = element.first_simpleType);
|
||||
INCLUDE simpleType/POD/structure.tt(simpleType = type);
|
||||
RETURN;
|
||||
INCLUDE simpleType/POD/structure.tt(simpleType = type);
|
||||
RETURN;
|
||||
ELSIF (type = element.first_complexType);
|
||||
INCLUDE complexType/POD/structure.tt(complexType = type);
|
||||
INCLUDE complexType/POD/structure.tt(complexType = type);
|
||||
ELSE;
|
||||
THROW NOT_FOUND, "no type found for ${element.get_name}";
|
||||
THROW NOT_FOUND, "no type found for ${element.get_name}";
|
||||
%]
|
||||
NO TYPE FOUND FOR ELEMENT [% element.get_name %]
|
||||
NO TYPE FOUND FOR ELEMENT [% element.get_name %]
|
||||
[% END -%]
|
||||
@@ -5,8 +5,8 @@ use warnings;
|
||||
sub get_xmlns { '[% simpleType.get_targetNamespace %]'};
|
||||
|
||||
[% INCLUDE simpleType/contentModel.tt %]
|
||||
[%#
|
||||
# Don't include any perl source here - there may be sub-packages...
|
||||
[%#
|
||||
# Don't include any perl source here - there may be sub-packages...
|
||||
#-%]
|
||||
|
||||
1;
|
||||
@@ -20,12 +20,12 @@ sub get_xmlns { '[% simpleType.get_targetNamespace %]'};
|
||||
Perl data type class for the XML Schema defined simpleType
|
||||
[% simpleType.get_name %] from the namespace [% simpleType.get_targetNamespace %].
|
||||
|
||||
[% IF (simpleType.get_variety == 'list');
|
||||
INCLUDE simpleType/POD/list.tt;
|
||||
ELSIF (simpleType.get_variety == 'restriction');
|
||||
INCLUDE simpleType/POD/restriction.tt;
|
||||
ELSE;
|
||||
THROW NOT_IMPLEMENTED "simpleType union not implemented yet in $simpleType.get_name";
|
||||
[% IF (simpleType.get_variety == 'list');
|
||||
INCLUDE simpleType/POD/list.tt;
|
||||
ELSIF (simpleType.get_variety == 'restriction');
|
||||
INCLUDE simpleType/POD/restriction.tt;
|
||||
ELSE;
|
||||
THROW NOT_IMPLEMENTED "simpleType union not implemented yet in $simpleType.get_name";
|
||||
END %]
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
This clase is derived from
|
||||
[%-
|
||||
[%-
|
||||
IF (name = simpleType.get_itemType);
|
||||
type_name = simpleType.expand( name );
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
type_name = simpleType.expand( name );
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
SOAP::WSDL::XSD::Typelib::Builtin::[% type_name.1 %]
|
||||
[% ELSE -%]
|
||||
[% type_prefix %]::[% type_name.1 %]
|
||||
[% END;
|
||||
[% ELSE -%]
|
||||
[% type_prefix %]::[% type_name.1 %]
|
||||
[% END;
|
||||
ELSE;
|
||||
# THROW NOT_IMPLEMENTED "atomic simpleType list not implemented yet in $simpleType.get_name";
|
||||
%] a atomic base type. Unfortunately there's no documenatation generation for atomic base types yet. [%
|
||||
# THROW NOT_IMPLEMENTED "atomic simpleType list not implemented yet in $simpleType.get_name";
|
||||
%] a atomic base type. Unfortunately there's no documenatation generation for atomic base types yet. [%
|
||||
END -%].
|
||||
|
||||
You may pass the following structure to new():
|
||||
|
||||
[ $value_1, .. $value_n ]
|
||||
|
||||
All elements of the list must be of the class' base type (or
|
||||
valid arguments to it's constructor).
|
||||
All elements of the list must be of the class' base type (or valid arguments
|
||||
to it's constructor).
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
This clase is derived from
|
||||
[%-
|
||||
This clase is derived from [%-
|
||||
IF (name = simpleType.get_base);
|
||||
type_name = simpleType.expand( name );
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
type_name = simpleType.expand( name );
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
SOAP::WSDL::XSD::Typelib::Builtin::[% type_name.1 %]
|
||||
[% ELSE -%]
|
||||
[% type_prefix %]::[% type_name.1 %]
|
||||
[% END;
|
||||
[% ELSE -%]
|
||||
[% type_prefix %]::[% type_name.1 %]
|
||||
[% END;
|
||||
ELSE;
|
||||
# THROW NOT_IMPLEMENTED "atomic simpleType restriction not implemented yet in $simpleType.get_name";
|
||||
%] a atomic base type. Unfortunately there's no documenatation generation for atomic base types yet. [%
|
||||
# THROW NOT_IMPLEMENTED "atomic simpleType restriction not implemented yet in $simpleType.get_name";
|
||||
%] a atomic base type. Unfortunately there's no documenatation generation for atomic base types yet. [%
|
||||
END -%]
|
||||
. SOAP::WSDL's schema implementation does not validate data, so you can use it exactly
|
||||
. SOAP::WSDL's schema implementation does not validate data, so you can use it exactly
|
||||
like it's base type.
|
||||
|
||||
# Description of restrictions not implemented yet.
|
||||
@@ -1,7 +1,7 @@
|
||||
[% IF (simpleType.get_variety == 'list');
|
||||
INCLUDE simpleType/list.tt(simpleType = simpleType);
|
||||
[% IF (simpleType.get_variety == 'list');
|
||||
INCLUDE simpleType/list.tt(simpleType = simpleType);
|
||||
ELSIF (simpleType.get_variety == 'restriction');
|
||||
INCLUDE simpleType/restriction.tt(type = simpleType);
|
||||
ELSE;
|
||||
THROW NOT_IMPLEMENTED "${ element.get_name } - ${ simpleType.get_variety } not supported yet";
|
||||
INCLUDE simpleType/restriction.tt(type = simpleType);
|
||||
ELSE;
|
||||
THROW NOT_IMPLEMENTED "${ element.get_name } - ${ simpleType.get_variety } not supported yet";
|
||||
END %]
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
# list derivation
|
||||
use base qw(
|
||||
SOAP::WSDL::XSD::Typelib::Builtin::list
|
||||
[%
|
||||
SOAP::WSDL::XSD::Typelib::Builtin::list
|
||||
[%
|
||||
IF (name = simpleType.get_itemType);
|
||||
type_name = simpleType.expand( name );
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
SOAP::WSDL::XSD::Typelib::Builtin::[% type_name.1 %]
|
||||
type_name = simpleType.expand( name );
|
||||
IF (type_name.0 == 'http://www.w3.org/2001/XMLSchema'); -%]
|
||||
SOAP::WSDL::XSD::Typelib::Builtin::[% type_name.1 %]
|
||||
);
|
||||
[% ELSE -%]
|
||||
[% type_prefix %]::[% type_name.1 %]
|
||||
[% ELSE -%]
|
||||
[% type_prefix %]::[% type_name.1 %]
|
||||
);
|
||||
[% END;
|
||||
[% END;
|
||||
ELSIF (type = simpleType.first_simpleType); %]
|
||||
);
|
||||
|
||||
[% INCLUDE simpleType/atomicType.tt(type = type);
|
||||
[% INCLUDE simpleType/atomicType.tt(type = type);
|
||||
ELSE; PERL %]die $stash->{simpleType}._DUMP [% END;
|
||||
THROW UNKNOWN , "No list itemTape and no atomic simpleType - don't know what to do";
|
||||
THROW UNKNOWN , "No list itemTape and no atomic simpleType - don't know what to do";
|
||||
END %]
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# derivation by restriction
|
||||
[% IF (base = simpleType.get_base) -%]
|
||||
use base qw(
|
||||
[% INCLUDE _type_class.tt(type = base, node=simpleType) %]);
|
||||
[% INCLUDE _type_class.tt(type = base, node=simpleType) %]);
|
||||
[% ELSIF (type = simpleType.first_simpleType() );
|
||||
INCLUDE simpleType/atomicType.tt(type = type);
|
||||
INCLUDE simpleType/atomicType.tt(type = type);
|
||||
ELSE;
|
||||
THROW "neither base nor atomic type - don't know what to do" %]
|
||||
THROW "neither base nor atomic type - don't know what to do" %]
|
||||
[% END %]
|
||||
@@ -11,9 +11,9 @@ my %element_prefix_of :ATTR(:name<element_prefix> :default<()>);
|
||||
|
||||
sub START {
|
||||
my ($self, $ident, $arg_ref) = @_;
|
||||
$type_prefix_of{ $ident } = 'MyType' if not exists
|
||||
$type_prefix_of{ $ident } = 'MyType' if not exists
|
||||
$arg_ref->{ 'type_prefix' };
|
||||
$element_prefix_of{ $ident } = 'MyElement' if not exists
|
||||
$element_prefix_of{ $ident } = 'MyElement' if not exists
|
||||
$arg_ref->{ 'element_prefix' };
|
||||
|
||||
}
|
||||
@@ -48,53 +48,53 @@ SOAP::WSDL::Generator::Visitor - SOAP::WSDL's Visitor-based Code Generator
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SOAP::WSDL featores a code generating facility. This code generation facility
|
||||
(in fact there are several of them) is implemented as Visitor to
|
||||
SOAP::WSDL featores a code generating facility. This code generation facility
|
||||
(in fact there are several of them) is implemented as Visitor to
|
||||
SOAP::WSDL::Base-derived objects.
|
||||
|
||||
=head2 The Visitor Pattern
|
||||
|
||||
The Visitor design pattern is one of the object oriented design pattern
|
||||
The Visitor design pattern is one of the object oriented design pattern
|
||||
described by [GHJV1995].
|
||||
|
||||
A Visitor is an object implementing some behaviour for a fixed set of classes,
|
||||
whose implementation would otherwise need to be scattered accross those
|
||||
A Visitor is an object implementing some behaviour for a fixed set of classes,
|
||||
whose implementation would otherwise need to be scattered accross those
|
||||
classes' implementations.
|
||||
|
||||
Visitors are usually combined with Iterators for traversing either a list or
|
||||
Visitors are usually combined with Iterators for traversing either a list or
|
||||
tree of objects.
|
||||
|
||||
A Visitor's methods are called using the so-called double dispatch technique.
|
||||
To allow double dispatching, the Visitor implements one method for every class
|
||||
ro be handled, whereas every class implements just one method (commonly named
|
||||
"access"), which does nothing more than calling a method on the reference
|
||||
A Visitor's methods are called using the so-called double dispatch technique.
|
||||
To allow double dispatching, the Visitor implements one method for every class
|
||||
ro be handled, whereas every class implements just one method (commonly named
|
||||
"access"), which does nothing more than calling a method on the reference
|
||||
given, with the self object as parameter.
|
||||
|
||||
If all this sounds strange, maybe an example helps. Imagine you had a list of
|
||||
person objects and wanted to print out a list of their names (or address
|
||||
stamps or everything elseyou like). This can easily be implemented with a
|
||||
Visitor:
|
||||
If all this sounds strange, maybe an example helps. Imagine you had a list of
|
||||
person objects and wanted to print out a list of their names (or address
|
||||
stamps or everything elseyou like). This can easily be implemented with a
|
||||
Visitor:
|
||||
|
||||
package PersonVisitor;
|
||||
use Class::Std; # handles all basic stuff like constructors etc.
|
||||
|
||||
|
||||
sub visit_Person {
|
||||
my ( $self, $object ) = @_;
|
||||
print "Person name is ", $object->get_name(), "\n";
|
||||
}
|
||||
|
||||
|
||||
package Person;
|
||||
use Class::Std;
|
||||
my %name : ATTR(:name<name> :default<anonymous>);
|
||||
|
||||
|
||||
sub accept { $_[1]->visit_Person( $_[0] ) }
|
||||
|
||||
|
||||
package main;
|
||||
my @person_from = ();
|
||||
for (qw(Gamma Helm Johnson Vlissides)) {
|
||||
push @person_from, Person->new( { name => $_ } );
|
||||
}
|
||||
|
||||
|
||||
my $visitor = PersonVisitor->new();
|
||||
for (@person_from) {
|
||||
$_->accept($visitor);
|
||||
@@ -106,8 +106,8 @@ Visitor:
|
||||
Person name is Johnson
|
||||
Person name is Vlissides
|
||||
|
||||
While using this pattern for just printing a list may look a bit over-sized,
|
||||
but it may become handy if you need multiple output formats and different
|
||||
While using this pattern for just printing a list may look a bit over-sized,
|
||||
but it may become handy if you need multiple output formats and different
|
||||
classes to operate on.
|
||||
|
||||
The main benefits using visitors are:
|
||||
@@ -116,19 +116,19 @@ The main benefits using visitors are:
|
||||
|
||||
=item * Grouping related behaviour in one class
|
||||
|
||||
Related behaviour for several classes can be grouped together in the Visitor
|
||||
class. The behaviour can easily be changed by changing the code in one class,
|
||||
Related behaviour for several classes can be grouped together in the Visitor
|
||||
class. The behaviour can easily be changed by changing the code in one class,
|
||||
instead of having to change all the visited classes.
|
||||
|
||||
=item * Cleaning up the data classes' implementations
|
||||
|
||||
If classes holding data also implement several different output formats or
|
||||
If classes holding data also implement several different output formats or
|
||||
other (otherwise unrelated) behaviour, they tend to get bloated.
|
||||
|
||||
=item * Adding behaviour is easy
|
||||
=item * Adding behaviour is easy
|
||||
|
||||
Swapping out the visitor class allows easy alterations of behaviour. So on a
|
||||
list of Persons, one Visitor may print address stamps, while another one prints
|
||||
Swapping out the visitor class allows easy alterations of behaviour. So on a
|
||||
list of Persons, one Visitor may print address stamps, while another one prints
|
||||
out a phone number list.
|
||||
|
||||
=back
|
||||
@@ -139,19 +139,19 @@ Of course, there are also drawbacks in the visitor pattern:
|
||||
|
||||
=item * Changes in the visited classes are expensive
|
||||
|
||||
If one of the visited classes changes (or is added), all visitors must be
|
||||
updated to reflect this change. This may be rather expensive if classes change
|
||||
If one of the visited classes changes (or is added), all visitors must be
|
||||
updated to reflect this change. This may be rather expensive if classes change
|
||||
often.
|
||||
|
||||
=item * The visited classes must expose all data required
|
||||
|
||||
Visitors may need to use the internals of a class. This may result in fidelling
|
||||
Visitors may need to use the internals of a class. This may result in fidelling
|
||||
with a object's internals, or a bloated interface in the visited class.
|
||||
|
||||
=back
|
||||
|
||||
Visitors are usually accompanied by a Iterator. The Iterator may be implemented
|
||||
in the visited classes, in the Visitor, or somewhere else (in the example it
|
||||
Visitors are usually accompanied by a Iterator. The Iterator may be implemented
|
||||
in the visited classes, in the Visitor, or somewhere else (in the example it
|
||||
was somewhere else).
|
||||
|
||||
The Iterator decides which object to visit next.
|
||||
@@ -164,47 +164,47 @@ Code generation in SOAP::WSDL means generating various artefacts:
|
||||
|
||||
=item * Typemaps
|
||||
|
||||
For every WSDL definition, a Typemap is created. The Typemap is used later as
|
||||
For every WSDL definition, a Typemap is created. The Typemap is used later as
|
||||
an aid in parsing the SOAP XML messages.
|
||||
|
||||
=item * Type Classes
|
||||
|
||||
For every type defined in the WSDL's schema, a Type Class is generated.
|
||||
For every type defined in the WSDL's schema, a Type Class is generated.
|
||||
|
||||
These classes are instantiated later as a result of parsing SOAP XML messages.
|
||||
|
||||
=item * Interface Classes
|
||||
|
||||
For every service, a interface class is generated. This class is later used by
|
||||
For every service, a interface class is generated. This class is later used by
|
||||
programmers accessing the service
|
||||
|
||||
=item * Documentation
|
||||
|
||||
Both Type Classes and Interface Classes include documentation. Additional
|
||||
documentation may be generated as a hint for programmers, or later for
|
||||
Both Type Classes and Interface Classes include documentation. Additional
|
||||
documentation may be generated as a hint for programmers, or later for
|
||||
mimicing .NET's .asmx example pages.
|
||||
|
||||
=back
|
||||
|
||||
All these behaviours could well (and has historically been) implemented in the
|
||||
classes holding the WSDL data. This made these classes rather bloated, and
|
||||
made it hard to change behaviour (like, supporting SOAP Headers,
|
||||
supporting atomic types and other features which were missing from early
|
||||
All these behaviours could well (and has historically been) implemented in the
|
||||
classes holding the WSDL data. This made these classes rather bloated, and
|
||||
made it hard to change behaviour (like, supporting SOAP Headers,
|
||||
supporting atomic types and other features which were missing from early
|
||||
versions of SOAP::WSDL).
|
||||
|
||||
Implementing these behaviours in Visitor classes eases adding new behaviours,
|
||||
and reducing the incompletenesses still inherent in SOAP::WSDL's WSDL and XML
|
||||
Implementing these behaviours in Visitor classes eases adding new behaviours,
|
||||
and reducing the incompletenesses still inherent in SOAP::WSDL's WSDL and XML
|
||||
schema implementation.
|
||||
|
||||
=head2 Implementation
|
||||
|
||||
=head3 accept
|
||||
=head3 accept
|
||||
|
||||
SOAP::WSDL::Base defines an accept method which expects a Visitor as only
|
||||
SOAP::WSDL::Base defines an accept method which expects a Visitor as only
|
||||
parameter.
|
||||
|
||||
The method visit_Foo_Bar is called on the visitor, whith the self object as
|
||||
parameter.
|
||||
The method visit_Foo_Bar is called on the visitor, whith the self object as
|
||||
parameter.
|
||||
|
||||
The actual method name is constructed this way:
|
||||
|
||||
@@ -218,18 +218,18 @@ The actual method name is constructed this way:
|
||||
|
||||
Example:
|
||||
|
||||
When visiting a SOAP::WSDL::XSD::ComplexType object, the method
|
||||
When visiting a SOAP::WSDL::XSD::ComplexType object, the method
|
||||
visit_XSD_ComplexType is called on the visitor.
|
||||
|
||||
=head2 Writing your own visitor
|
||||
|
||||
SOAP::WSDL eases writing your own visitor. This might be required if you need
|
||||
some special output format from a WSDL file, or want to feed your own
|
||||
serializer/deserializer pair with custom configuration data. Or maybe you want
|
||||
SOAP::WSDL eases writing your own visitor. This might be required if you need
|
||||
some special output format from a WSDL file, or want to feed your own
|
||||
serializer/deserializer pair with custom configuration data. Or maybe you want
|
||||
to generate C# code from it...
|
||||
|
||||
To write your own code generating visitor, you should subclass
|
||||
SOAP::WSDL::Generator::Visitor. It implements (empty) default methods for all
|
||||
To write your own code generating visitor, you should subclass
|
||||
SOAP::WSDL::Generator::Visitor. It implements (empty) default methods for all
|
||||
SOAP::WSDL data classes:
|
||||
|
||||
=over
|
||||
@@ -264,16 +264,16 @@ SOAP::WSDL data classes:
|
||||
|
||||
=item * visit_XSD_SimpleType
|
||||
|
||||
=back
|
||||
=back
|
||||
|
||||
In your Visitor, you must implement visit_Foo methods for all classes you wish
|
||||
In your Visitor, you must implement visit_Foo methods for all classes you wish
|
||||
to visit.
|
||||
|
||||
Currently, all SOAP::WSDL::Generator::Visitor implementations include their own
|
||||
Iterator (which means they know how to find the next objects to visit). You
|
||||
may or may not choose to implement a separate Iterator.
|
||||
Currently, all SOAP::WSDL::Generator::Visitor implementations include their own
|
||||
Iterator (which means they know how to find the next objects to visit). You
|
||||
may or may not choose to implement a separate Iterator.
|
||||
|
||||
Letting a visitor implementing it's own Iterator visit a WSDL definition is as
|
||||
Letting a visitor implementing it's own Iterator visit a WSDL definition is as
|
||||
easy as writing something like this:
|
||||
|
||||
my $visitor = MyVisitor->new();
|
||||
@@ -284,21 +284,21 @@ easy as writing something like this:
|
||||
|
||||
=head1 REFERENCES
|
||||
|
||||
=over
|
||||
=over
|
||||
|
||||
=item * [GHJV1995]
|
||||
=item * [GHJV1995]
|
||||
|
||||
Erich Gamma, Richard Helm, Ralph E. Johnson, John Vlissides, (1995):
|
||||
Erich Gamma, Richard Helm, Ralph E. Johnson, John Vlissides, (1995):
|
||||
Design Patterns. Elements of Reusable Object-Oriented Software.
|
||||
Addison-Wesley Longman, Amsterdam.
|
||||
|
||||
=back
|
||||
=back
|
||||
|
||||
=head1 LICENSE
|
||||
=head1 LICENSE AND COPYRIGHT
|
||||
|
||||
Copyright 2004-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
|
||||
|
||||
@@ -18,32 +18,32 @@ sub START {
|
||||
|
||||
sub set_typemap_entry {
|
||||
my ($self, $value) = @_;
|
||||
$typemap_of{ ident $self }->{
|
||||
join( q{/}, @{ $path_of{ ident $self } } )
|
||||
} = $value;
|
||||
$typemap_of{ ident $self }->{
|
||||
join( q{/}, @{ $path_of{ ident $self } } )
|
||||
} = $value;
|
||||
}
|
||||
|
||||
sub add_element_path {
|
||||
my ($self, $element) = @_;
|
||||
|
||||
# Swapping out this lines against the ones below generates
|
||||
# Swapping out this lines against the ones below generates
|
||||
# a namespace-sensitive typemap.
|
||||
# Well almost: Class names are not constructed in a namespace-sensitive
|
||||
# Well almost: Class names are not constructed in a namespace-sensitive
|
||||
# manner, yet - there should be some facility to allow binding a (perl)
|
||||
# prefix to a namespace...
|
||||
push @{ $path_of{ ident $self } }, $element->get_name();
|
||||
|
||||
# push @{ $path_of{ ident $self } },
|
||||
# "{". $element->get_targetNamespace . "}"
|
||||
|
||||
# push @{ $path_of{ ident $self } },
|
||||
# "{". $element->get_targetNamespace . "}"
|
||||
# . $element->get_name();
|
||||
}
|
||||
}
|
||||
|
||||
sub visit_Definitions {
|
||||
my ( $self, $ident, $definitions ) = ( $_[0], ident $_[0], $_[1] );
|
||||
|
||||
$self->set_definitions( $definitions );
|
||||
$self->set_definitions( $definitions );
|
||||
|
||||
for ( @{ $definitions->get_service() } ) {
|
||||
for ( @{ $definitions->get_service() } ){
|
||||
$_->_accept($self);
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ sub visit_Binding {
|
||||
my $name = $operation->get_name();
|
||||
|
||||
# get the equally named operation from the portType
|
||||
my ($op) = grep { $_->get_name eq $name }
|
||||
my ($op) = grep { $_->get_name eq $name }
|
||||
@{ $portType->get_operation() }
|
||||
or die "operation <$name> not found";
|
||||
|
||||
@@ -122,14 +122,14 @@ sub visit_Part {
|
||||
# FIXME support RPC-style calls
|
||||
die "unsupported global type <$type_name> found in part";
|
||||
}
|
||||
|
||||
|
||||
# TODO factor out iterator or replace by lookup (probably better)
|
||||
if ( my $element_name = $part->get_element() ) {
|
||||
my $element = $types_ref->find_element(
|
||||
my $element = $types_ref->find_element(
|
||||
$part->expand($element_name) )
|
||||
|| die "no element $element_name found for part " . $part->get_name();
|
||||
$element->_accept($self);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
warn 'neither type nor element - do not know what to do for part '
|
||||
@@ -160,9 +160,9 @@ sub process_referenced_type {
|
||||
}
|
||||
|
||||
sub process_atomic_type {
|
||||
my ( $self, $type, $callback ) = @_;
|
||||
my ( $self, $type, $callback ) = @_;
|
||||
return if not $type;
|
||||
|
||||
|
||||
my $ident = ident $self;
|
||||
$callback->( $self, $type ) if $callback;
|
||||
return $self;
|
||||
@@ -171,40 +171,40 @@ sub process_atomic_type {
|
||||
sub visit_XSD_Element {
|
||||
my ( $self, $ident, $element ) = ( $_[0], ident $_[0], $_[1] );
|
||||
|
||||
# TODO: what about element ref="" ?
|
||||
# TODO: what about element ref="" ?
|
||||
# when we're hopping from one element to the next one...
|
||||
|
||||
# step down in tree
|
||||
$self->add_element_path( $element );
|
||||
|
||||
# now call all possible variants.
|
||||
# They all just return if no argument is given,
|
||||
# They all just return if no argument is given,
|
||||
# and return $self on success.
|
||||
SWITCH: {
|
||||
if ($element->get_type) {
|
||||
$self->process_referenced_type( $element->expand( $element->get_type() ) )
|
||||
if ($element->get_type) {
|
||||
$self->process_referenced_type( $element->expand( $element->get_type() ) )
|
||||
&& last;
|
||||
}
|
||||
# for atomic simple and comples types , and ref elements
|
||||
my $typeclass = join q{::}, $element_prefix_of{$ident}, $element->get_name();
|
||||
|
||||
|
||||
$self->set_typemap_entry($typeclass);
|
||||
|
||||
|
||||
# kind of double-dispatch: returns true on success, but does nothing
|
||||
$self->process_atomic_type( $element->first_simpleType() )
|
||||
&& last;
|
||||
|
||||
|
||||
$self->process_atomic_type( $element->first_complexType()
|
||||
, sub { $_[1]->_accept($_[0]) } )
|
||||
&& last;
|
||||
|
||||
# TODO: add element ref handling
|
||||
|
||||
# TODO: add element ref handling
|
||||
};
|
||||
# step up in hierarchy
|
||||
pop @{ $path_of{$ident} };
|
||||
}
|
||||
|
||||
sub visit_XSD_ComplexType {
|
||||
sub visit_XSD_ComplexType {
|
||||
my ($self, $ident, $type) = ($_[0], ident $_[0], $_[1] );
|
||||
my $content_model = $type->get_flavor();
|
||||
# TODO is this allowed ? or should we better die ?
|
||||
@@ -218,9 +218,9 @@ sub visit_XSD_ComplexType {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
warn "unsupported content model $content_model found in "
|
||||
. "complex type " . $type->get_name()
|
||||
. "complex type " . $type->get_name()
|
||||
. " - typemap may be incomplete";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user