Files
SOAP-WSDL/lib/SOAP/WSDL/Client/Base.pm
Martin Kutter 3b30e8d0e2 import SOAP-WSDL 2.00.09 from CPAN
git-cpan-module:   SOAP-WSDL
git-cpan-version:  2.00.09
git-cpan-authorid: MKUTTER
git-cpan-file:     authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00.09.tar.gz
2009-12-12 19:49:02 -08:00

94 lines
2.3 KiB
Perl

package SOAP::WSDL::Client::Base;
use strict;
use warnings;
use base 'SOAP::WSDL::Client';
use Scalar::Util qw(blessed);
use version; our $VERSION = qv('2.00.09');
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 @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 $@; ## no critic (ProhibitStringyEval)
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 } }) {
# treat non object special - as above, but only for one
if (not blessed $header) {
my $class = $method->{ header }->{ parts }->[0];
eval "require $class" || die $@; ## no critic (ProhibitStringyEval)
$header = $class->new($header);
}
}
return $self->SUPER::call($method, $body, $header);
}
1;
__END__
=pod
=head1 NAME
SOAP::WSDL::Client::Base - Factory class for WSDL-based SOAP access
=head1 SYNOPSIS
package MySoapInterface;
use SOAP::WSDL::Client::Base;
__PACKAGE__->__create_methods( qw(one two three) );
1;
=head1 DESCRIPTION
Factory class for creating interface classes. Should probably be renamed to
SOAP::WSDL::Factory::Interface...
=head1 METHODS
=head2 call
Abstraction layer method between the generated interfaces and
L<SOAP::WSDL::Client|SOAP::WSDL::Client>.
=head1 LICENSE AND COPYRIGHT
Copyright 2004-2007 Martin Kutter.
This file is part of SOAP-WSDL. You may distribute/modify it under the same
terms as perl itself
=head1 AUTHOR
Martin Kutter E<lt>martin.kutter fen-net.deE<gt>
=head1 REPOSITORY INFORMATION
$Rev: 805 $
$LastChangedBy: kutterma $
$Id: Base.pm 805 2009-02-23 21:12:24Z kutterma $
$HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Client/Base.pm $
=cut