SOAP::WSDL::Client::Base - Factory class for WSDL-based SOAP access


SOAP-WSDL documentation Contained in the SOAP-WSDL distribution.

Index


Code Index:

NAME

Top

SOAP::WSDL::Client::Base - Factory class for WSDL-based SOAP access

SYNOPSIS

Top

 package MySoapInterface;
 use SOAP::WSDL::Client::Base;
 __PACKAGE__->__create_methods( qw(one two three) );
 1;

DESCRIPTION

Top

Factory class for creating interface classes. Should probably be renamed to SOAP::WSDL::Factory::Interface...

METHODS

Top

call

Abstraction layer method between the generated interfaces and SOAP::WSDL::Client.

LICENSE AND COPYRIGHT

Top

AUTHOR

Top

Martin Kutter <martin.kutter fen-net.de>

REPOSITORY INFORMATION

Top

 $Rev: 851 $
 $LastChangedBy: kutterma $
 $Id: Base.pm 851 2009-05-15 22:45:18Z kutterma $
 $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Client/Base.pm $


SOAP-WSDL documentation Contained in the SOAP-WSDL distribution.

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.10');

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__