File: Base.pm

package info (click to toggle)
libsoap-wsdl-perl 3.004-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,600 kB
  • sloc: perl: 8,433; xml: 1,769; java: 19; makefile: 15
file content (93 lines) | stat: -rw-r--r-- 2,347 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package SOAP::WSDL::Client::Base;
use strict;
use warnings;
use base 'SOAP::WSDL::Client';
use Scalar::Util qw(blessed);

our $VERSION = 3.004;

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: 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 $

=cut