| 1 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com) | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # SOAP::Lite is free software; you can redistribute it | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # $Id$ | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | package XMLRPC::Lite; | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use SOAP::Lite; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | our $VERSION = 0.717; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | package XMLRPC::Constants; | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | for (qw( | |||||||||||||||||||||||||||||||||||||||||
| 25 | FAULT_CLIENT FAULT_SERVER | ||||||||||||||||||||||||||||||||||||||||||
| 26 | HTTP_ON_SUCCESS_CODE HTTP_ON_FAULT_CODE | ||||||||||||||||||||||||||||||||||||||||||
| 27 | DO_NOT_USE_XML_PARSER DO_NOT_USE_CHARSET | ||||||||||||||||||||||||||||||||||||||||||
| 28 | DO_NOT_USE_LWP_LENGTH_HACK DO_NOT_CHECK_CONTENT_TYPE | ||||||||||||||||||||||||||||||||||||||||||
| 29 | )) { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 24 | *$_ = \${'SOAP::Constants::' . $_} | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # XML-RPC spec requires content-type to be "text/xml" | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | $XMLRPC::Constants::DO_NOT_USE_CHARSET = 1; | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | package XMLRPC::Data; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | @XMLRPC::Data::ISA = qw(SOAP::Data); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | package XMLRPC::Serializer; | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | @XMLRPC::Serializer::ISA = qw(SOAP::Serializer); | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 44 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 44 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 44 | ▶ | return $class if ref $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | return $class->SUPER::new( | ||||||||||||||||||||||||||||||||||||||||||
| 54 | typelookup => { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 15 | ▶ | base64 => [10, sub {$_[0] =~ /[^\x09\x0a\x0d\x20-\x7f]/}, 'as_base64'], | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 15 | ▶ | int => [20, sub {$_[0] =~ /^[+-]?\d+$/}, 'as_int'], | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | ▶ | double => [30, sub {$_[0] =~ /^(-?(?:\d+(?:\.\d*)?|\.\d+)|([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?)$/}, 'as_double'], | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | dateTime => [35, sub {$_[0] =~ /^\d{8}T\d\d:\d\d:\d\d$/}, 'as_dateTime'], | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 11 | ▶ | string => [40, sub {1}, 'as_string'], | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | attr => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | namespaces => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | @_, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 9 | ▶ | sub envelope { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
envelope: called CC=8 SCAR=25.3
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 9 | ▶ | $self = $self->new() if not ref $self; # serves a method call if object | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 9 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 9 | my $body; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 9 | ▶ | if ($type eq 'response') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | # shift off method name to make XMLRPT happy | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my $method = shift | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | or die "Unspecified method for XMLRPC call\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $body = XMLRPC::Data->name( methodResponse => \XMLRPC::Data->value( | |||||||||||||||||||||||||||||||||||||||||
| 78 | XMLRPC::Data->type(params => [@_]) | ||||||||||||||||||||||||||||||||||||||||||
| 79 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | elsif ($type eq 'method') { | ||||||||||||||||||||||||||||||||||||||||||
| 83 | # shift off method name to make XMLRPT happy | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 9 | ▶ | my $method = shift | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | or die "Unspecified method for XMLRPC call\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 9 | ▶ | $body = XMLRPC::Data->name( methodCall => \XMLRPC::Data->value( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | XMLRPC::Data->type( | ||||||||||||||||||||||||||||||||||||||||||
| 88 | methodName => UNIVERSAL::isa($method => 'XMLRPC::Data') | ||||||||||||||||||||||||||||||||||||||||||
| 89 | ? $method->name | ||||||||||||||||||||||||||||||||||||||||||
| 90 | : $method | ||||||||||||||||||||||||||||||||||||||||||
| 91 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 92 | XMLRPC::Data->type(params => [@_]) | ||||||||||||||||||||||||||||||||||||||||||
| 93 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | elsif ($type eq 'fault') { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $body = XMLRPC::Data->name(methodResponse => | |||||||||||||||||||||||||||||||||||||||||
| 97 | \XMLRPC::Data->type(fault => {faultCode => $_[0], faultString => $_[1]}), | ||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | die "Wrong type of envelope ($type) for XMLRPC call\n"; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | # SOAP::Lite keeps track of objects for XML aliasing and multiref | ||||||||||||||||||||||||||||||||||||||||||
| 105 | # encoding. | ||||||||||||||||||||||||||||||||||||||||||
| 106 | # Set/reset seen() hashref before/after encode_object avoids a | ||||||||||||||||||||||||||||||||||||||||||
| 107 | # memory leak | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 9 | $self->seen({}); # initialize multiref table | |||||||||||||||||||||||||||||||||||||||||
| 109 | 9 | my $envelope = $self->xmlize($self->encode_object($body)); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 9 | $self->seen({}); # delete multi-ref table - avoids a memory hole... | |||||||||||||||||||||||||||||||||||||||||
| 111 | 9 | return $envelope; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 68 | ▶ | sub encode_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_object: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 68 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 68 | my @encoded = $self->SUPER::encode_object(@_); | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 67 | ▶ | return $encoded[0]->[0] =~ /^(?:array|struct|i4|int|boolean|string|double|dateTime\.iso8601|base64)$/o | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | ? ['value', {}, [@encoded]] | ||||||||||||||||||||||||||||||||||||||||||
| 121 | : @encoded; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 26 | ▶ | sub encode_scalar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_scalar: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 26 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 26 | ▶ | return ['value', {}] unless defined $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 24 | return $self->SUPER::encode_scalar(@_); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | ▶ | sub encode_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_array: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | my ($self, $array) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | return ['array', {}, [ | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | ['data', {}, [ map {$self->encode_object($_)} @{ $array } ] ] | |||||||||||||||||||||||||||||||||||||||||
| 135 | ]]; | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | ▶ | sub encode_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_hash: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | my ($self, $hash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | return ['struct', {}, [ | ||||||||||||||||||||||||||||||||||||||||||
| 142 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 9 | ['member', {}, [['name', {}, SOAP::Utils::encode_data($_)], $self->encode_object($hash->{$_})]] | |||||||||||||||||||||||||||||||||||||||||
| 144 | 4 | } keys %{ $hash } | |||||||||||||||||||||||||||||||||||||||||
| 145 | ]]; | ||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 9 | ▶ | sub as_methodName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_methodName: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 9 | my ($self, $value, $name, $type, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 9 | return [ 'methodName', $attr, $value ]; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 9 | ▶ | sub as_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 9 | my ($self, $params, $name, $type, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 155 | return ['params', $attr, [ | ||||||||||||||||||||||||||||||||||||||||||
| 156 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 9 | ['param', {}, [ $self->encode_object($_) ] ] | |||||||||||||||||||||||||||||||||||||||||
| 158 | } @$params | ||||||||||||||||||||||||||||||||||||||||||
| 159 | ]]; | ||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub as_fault { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_fault: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my ($self, $fault) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return ['fault', {}, [ $self->encode_object($fault) ] ]; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | ▶ | sub BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | for my $type (qw(double i4 int)) { | |||||||||||||||||||||||||||||||||||||||||
| 170 | 9 | my $method = 'as_' . $type; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 11 | ▶ | *$method = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 11 | my($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 11 | return [ $type, {}, $value ]; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 9 | } | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub as_base64 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_base64: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return ['base64', {}, MIME::Base64::encode_base64($value,'')]; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 4 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 4 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 4 | return ['string', {}, SOAP::Utils::encode_data($value)]; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub as_dateTime { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_dateTime: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return ['dateTime.iso8601', {}, $value]; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub as_boolean { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_boolean: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | return ['boolean', {}, $value ? 1 : 0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 28 | ▶ | sub typecast { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
typecast: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 28 | my ($self, $value, $name, $type, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 28 | ▶ | die "Wrong/unsupported datatype '$type' specified\n" if defined $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 27 | $self->SUPER::typecast(@_); | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | package XMLRPC::SOM; | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 3 | @XMLRPC::SOM::ISA = qw(SOAP::SOM); | |||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 3 | ▶ | sub BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | my %path = ( | |||||||||||||||||||||||||||||||||||||||||
| 216 | root => '/', | ||||||||||||||||||||||||||||||||||||||||||
| 217 | envelope => '/[1]', | ||||||||||||||||||||||||||||||||||||||||||
| 218 | method => '/methodCall/methodName', | ||||||||||||||||||||||||||||||||||||||||||
| 219 | fault => '/methodResponse/fault', | ||||||||||||||||||||||||||||||||||||||||||
| 220 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 3 | for my $method (keys %path) { | |||||||||||||||||||||||||||||||||||||||||
| 223 | 20 | ▶ | *$method = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 20 | ▶ | ref $self or return $path{$method}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 20 | ▶ | Carp::croak "Method '$method' is readonly and doesn't accept any parameters" if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 20 | $self->valueof($path{$method}); | |||||||||||||||||||||||||||||||||||||||||
| 228 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | my %fault = ( | |||||||||||||||||||||||||||||||||||||||||
| 232 | faultcode => 'faultCode', | ||||||||||||||||||||||||||||||||||||||||||
| 233 | faultstring => 'faultString', | ||||||||||||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 3 | for my $method (keys %fault) { | |||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | ▶ | *$method = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | ref $self or Carp::croak "Method '$method' doesn't have shortcut"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | ▶ | Carp::croak "Method '$method' is readonly and doesn't accept any parameters" if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | ▶ | defined $self->fault ? $self->fault->{$fault{$method}} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 3 | my %results = ( | |||||||||||||||||||||||||||||||||||||||||
| 246 | result => '/methodResponse/params/[1]', | ||||||||||||||||||||||||||||||||||||||||||
| 247 | paramsin => '/methodCall/params/param', | ||||||||||||||||||||||||||||||||||||||||||
| 248 | paramsall => '/methodResponse/params/param', | ||||||||||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 3 | for my $method (keys %results) { | |||||||||||||||||||||||||||||||||||||||||
| 252 | 5 | ▶ | *$method = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 5 | ▶ | ref $self or return $results{$method}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 5 | ▶ | Carp::croak "Method '$method' is readonly and doesn't accept any parameters" if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | defined $self->fault() | ||||||||||||||||||||||||||||||||||||||||||
| 257 | ? undef | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 5 | ▶ | : $self->valueof($results{$method}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | package XMLRPC::Deserializer; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | @XMLRPC::Deserializer::ISA = qw(SOAP::Deserializer); | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | for my $method (qw(o_child o_qname o_chars)) { # import from SOAP::Utils | |||||||||||||||||||||||||||||||||||||||||
| 272 | 9 | *$method = \&{'SOAP::Utils::'.$method}; | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 9 | ▶ | sub deserialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deserialize: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | # just deserialize with SOAP::Lite's deserializer, and re-bless as | ||||||||||||||||||||||||||||||||||||||||||
| 278 | # XMLRPC::SOM | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 9 | bless shift->SUPER::deserialize(@_) => 'XMLRPC::SOM'; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 50 | ▶ | sub decode_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_value: called CC=16 SCAR=32.0
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 50 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 50 | my $ref = shift; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 50 | my($name, $attrs, $children, $value) = @$ref; | |||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 50 | ▶ | if ($name eq 'value') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 16 | ▶ | $children ? scalar(($self->decode_object($children->[0]))[1]) : $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | elsif ($name eq 'array') { | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | return [map {scalar(($self->decode_object($_))[1])} @{o_child($children->[0]) || []}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
o_child($children->[0]) || []
MC/DC0%0/1
o_child($children->[0]) || []
o_child($children->[0])
Truth table0%0/2
A
A= o_child($children->[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | elsif ($name eq 'struct') { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 8 | ▶ | my %hash = map { o_qname($_) => $_ } @{o_child($_) || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
o_child($_) || []
MC/DC0%0/1
o_child($_) || []
o_child($_)
Truth table50%1/2
A
A= o_child($_)
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | # v----- scalar is required here, because 5.005 evaluates 'undef' in list context as empty array | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 8 | (o_chars($hash{name}) => scalar(($self->decode_object($hash{value}))[1])); | |||||||||||||||||||||||||||||||||||||||||
| 299 | 4 | ▶ | } @{$children || []}}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$children || []
MC/DC0%0/1
$children || []
$children
Truth table50%1/2
A
A= $children
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | elsif ($name eq 'base64') { | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | MIME::Base64::decode_base64($value); | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | elsif ($name =~ /^(?:int|i4|boolean|string|double|dateTime\.iso8601|methodName)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 11 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | elsif ($name =~ /^(?:params)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 5 | ▶ | return [map {scalar(($self->decode_object($_))[1])} @{$children || []}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$children || []
MC/DC0%0/1
$children || []
$children
Truth table50%1/2
A
A= $children
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | elsif ($name =~ /^(?:methodResponse|methodCall)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 7 | ▶ | return +{map {$self->decode_object($_)} @{$children || []}}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$children || []
MC/DC0%0/1
$children || []
$children
Truth table50%1/2
A
A= $children
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | elsif ($name =~ /^(?:param|fault)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 7 | return scalar(($self->decode_object($children->[0]))[1]); | |||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | elsif ($name =~ /^(?:nil)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | die "wrong element '$name'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | package XMLRPC::Server; | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | @XMLRPC::Server::ISA = qw(SOAP::Server); | |||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub initialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 333 | deserializer => XMLRPC::Deserializer->new, | ||||||||||||||||||||||||||||||||||||||||||
| 334 | serializer => XMLRPC::Serializer->new, | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | on_action => sub {}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | on_dispatch => sub { return map {s!\.!/!g; $_} shift->method =~ /^(?:(.*)\.)?(\w+)$/ }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | package XMLRPC::Server::Parameters; | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 3 | @XMLRPC::Server::Parameters::ISA = qw(SOAP::Server::Parameters); | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | package XMLRPC; | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 3 | @XMLRPC::ISA = qw(SOAP); | |||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | package XMLRPC::Lite; | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 3 | @XMLRPC::Lite::ISA = qw(SOAP::Lite); | |||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 122 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 122 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 122 | ▶ | return $class if ref $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | return $class->SUPER::new( | ||||||||||||||||||||||||||||||||||||||||||
| 364 | serializer => XMLRPC::Serializer->new, | ||||||||||||||||||||||||||||||||||||||||||
| 365 | deserializer => XMLRPC::Deserializer->new, | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 7 | ▶ | on_action => sub {return}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 7 | default_ns => 'http://unspecified/', | |||||||||||||||||||||||||||||||||||||||||
| 368 | @_ | ||||||||||||||||||||||||||||||||||||||||||
| 369 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | # ====================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | __END__ | ||||||||||||||||||||||||||||||||||||||||||