| 1 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # FILE: Serialize.pm | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # DESCRIPTION: SOAP::DirectI::Serialize -- serialization of requests to DirectI | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # FILES: --- | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # BUGS: --- | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # NOTES: --- | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # AUTHOR: Pavel Boldin (), <davinchi@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # COMPANY: | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # VERSION: 1.0 | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # CREATED: 18.03.2009 13:38:32 MSK | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # REVISION: --- | ||||||||||||||||||||||||||||||||||||||||||
| 16 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | package SOAP::DirectI::Serialize; | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | sub hash_to_soap { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hash_to_soap: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my ($data, $signature) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | my @output; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | push @output, $self->request_prefix( $signature ); | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | my $args = $signature->{ args }; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | push @output, $self->serialize_args( $args, $data ); | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | push @output, $self->request_suffix( $signature ); | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | #warn @output; | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | return join '', @output; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | sub serialize_args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize_args: called CC=7 SCAR=21.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | my @output; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | foreach my $arg (@$args) { | |||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | my $hash_key = $arg->{hash_key }; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | my $key = $arg->{key }; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | ▶ | if ( not $hash_key ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | $hash_key = join '_', map { lc $_ } ($key =~ m/([A-Z]?[a-z0-9]+)/g); | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | ▶ | if ( ! exists $data->{ $hash_key } && $arg->{required} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $data->{$hash_key} and $arg->{"required"}
MC/DC0%0/2
not exists $data->{$hash_key} and $arg->{"required"}
not exists $data->{$hash_key}
$arg->{"required"}
Truth table33%1/3
not(A) and B
A= not exists $data->{$hash_key}B= $arg->{"required"}
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | croak "Required field $key missed"; | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | #warn $hash_key; | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | my $d = $data->{ $hash_key }; | |||||||||||||||||||||||||||||||||||||||||
| 66 | # NOTE FUCKING RECURSION! | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | ▶ | if ( ! $d && (my $s = $self->can('_default_value_'.$hash_key)) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $d and my $s = $self->can('_default_value_' . $hash_key)
MC/DC0%0/2
not $d and my $s = $self->can('_default_value_' . $hash_key)
not $d
my $s = $self->can('_default_value_' . $hash_key)
Truth table33%1/3
not(A) and B
A= not $dB= my $s = $self->can('_default_value_' . $hash_key)
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $d = $s->( $self, $arg, $data ); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | #my $t = $arg ->{ type }; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | push @output, $self->serialize( $arg, $d ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | return @output; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | sub request_prefix { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_prefix: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | my ($self, $signature) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | ▶ | $signature->{namespace} ||= 'com.logicboxes.foundation.sfnb.user.Customer'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$signature->{"namespace"} ||= "com.logicboxes.foundation.sfnb.user.Customer"
MC/DC0%0/1
$signature->{"namespace"} ||= "com.logicboxes.foundation.sfnb.user.Customer"
$signature->{"namespace"}
Truth table50%1/2
A
A= $signature->{"namespace"}
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | return <<EOF | ||||||||||||||||||||||||||||||||||||||||||
| 85 | <?xml version="1.0" encoding="UTF-8"?> | ||||||||||||||||||||||||||||||||||||||||||
| 86 | <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="$signature->{namespace}"> | ||||||||||||||||||||||||||||||||||||||||||
| 87 | <SOAP-ENV:Body> | ||||||||||||||||||||||||||||||||||||||||||
| 88 | <impl:$signature->{name}> | ||||||||||||||||||||||||||||||||||||||||||
| 89 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | ▶ | sub request_suffix { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_suffix: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | my ($self, $signature) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | return <<EOF; | |||||||||||||||||||||||||||||||||||||||||
| 95 | \n | ||||||||||||||||||||||||||||||||||||||||||
| 96 | </impl:$signature->{name}> | ||||||||||||||||||||||||||||||||||||||||||
| 97 | </SOAP-ENV:Body> | ||||||||||||||||||||||||||||||||||||||||||
| 98 | </SOAP-ENV:Envelope> | ||||||||||||||||||||||||||||||||||||||||||
| 99 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 12 | ▶ | sub serialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize: called CC=2 SCAR=8.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 12 | my ($self, $arg, $d) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 12 | ▶ | if ( my $serializer = $self->can('serialize_'.$arg->{type}) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 12 | return $serializer->( $self, $arg, $d ); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return _serialize_simple( $arg, $d ); | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | croak "Cannot find serializer for $arg->{type}"; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | sub serialize_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize_array: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | return _serialize_array_or_vector( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub serialize_vector { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize_vector: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | return _serialize_array_or_vector( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | ▶ | sub serialize_map { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize_map: called CC=9 SCAR=22.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | my ($self, $arg, $hash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | ▶ | if ( ref $hash ne 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | croak "$arg->{key} is not HASH ref"; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | #warn Dumper $hash; | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | ▶ | if ( ! exists $arg->{key_sig} && exists $arg->{key_type} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $arg->{"key_sig"} and exists $arg->{"key_type"}
MC/DC0%0/2
not exists $arg->{"key_sig"} and exists $arg->{"key_type"}
not exists $arg->{"key_sig"}
exists $arg->{"key_type"}
Truth table33%1/3
not(A) and B
A= not exists $arg->{"key_sig"}B= exists $arg->{"key_type"}
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | $arg->{key_sig} = { | ||||||||||||||||||||||||||||||||||||||||||
| 134 | type => $arg->{key_type}, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | key => 'key', | |||||||||||||||||||||||||||||||||||||||||
| 136 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | ▶ | if ( ! exists $arg->{value_sig} && exists $arg->{value_type} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not exists $arg->{"value_sig"} and exists $arg->{"value_type"}
MC/DC50%1/2
not exists $arg->{"value_sig"} and exists $arg->{"value_type"}
not exists $arg->{"value_sig"}
exists $arg->{"value_type"}
Truth table66%2/3
not(A) and B
A= not exists $arg->{"value_sig"}B= exists $arg->{"value_type"}
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | $arg->{value_sig} = { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | type => $arg->{value_type}, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | key => 'value', | |||||||||||||||||||||||||||||||||||||||||
| 144 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | my $key_sig = $arg->{key_sig} | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | or croak "Unspecified key type for $arg->{key} map"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | my $value_sig = $arg->{value_sig} | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 3 | ▶ | or croak "Unspecified key type for $arg->{key} map"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | my @output; | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | push @output, _tag_start( $arg->{key}, q{xsi:type="apachesoap:Map"}); | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | ▶ | while ( my ( $k, $v ) = each %$hash ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 4 | my @pair; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 4 | push @pair, q{<item>}; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 4 | push @pair, $self->serialize( | |||||||||||||||||||||||||||||||||||||||||
| 161 | $key_sig, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | $k | ||||||||||||||||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 4 | push @pair, $self->serialize( | |||||||||||||||||||||||||||||||||||||||||
| 165 | $value_sig, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | $v | ||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | push @pair, q{</item>}; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | push @output, @pair; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | push @output, _tag_stop( $arg->{key} ); | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | return join '', @output; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | sub _serialize_array_or_vector { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_serialize_array_or_vector: called CC=7 SCAR=20.5
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | my ($self, $arg, $array) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | ▶ | if ( ref $array ne 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | croak "$arg->{key} is not ARRAY ref"; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | ▶ | if ( ! exists $arg->{elem_sig} && exists $arg->{elem_type} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $arg->{"elem_sig"} and exists $arg->{"elem_type"}
MC/DC0%0/2
not exists $arg->{"elem_sig"} and exists $arg->{"elem_type"}
not exists $arg->{"elem_sig"}
exists $arg->{"elem_type"}
Truth table33%1/3
not(A) and B
A= not exists $arg->{"elem_sig"}B= exists $arg->{"elem_type"}
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | $arg->{elem_sig} = { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | type => $arg->{elem_type}, | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | key => 'item', | |||||||||||||||||||||||||||||||||||||||||
| 190 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | my $elem_sig = $arg->{elem_sig} | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | or croak "Unspecified element type for $arg->{key} array"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | my @output; | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | my $attr = q{xsi:type="apachesoap:Vector"}; | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | if ( $arg->{type} eq 'array' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | my $elem_type_xml = get_xml_type( $elem_sig->{type} ); | |||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | my $length = scalar @$array; | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | $attr = | |||||||||||||||||||||||||||||||||||||||||
| 205 | q{xsi:type="SOAP-ENC:Array" }. | ||||||||||||||||||||||||||||||||||||||||||
| 206 | qq{SOAP-ENC:arrayType="$elem_type_xml\[$length]"}; | ||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | push @output, _tag_start( $arg->{key}, $attr ); | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | # my $fake_arg_signature = { | ||||||||||||||||||||||||||||||||||||||||||
| 212 | # key => 'item', | ||||||||||||||||||||||||||||||||||||||||||
| 213 | # type => $elem_type, | ||||||||||||||||||||||||||||||||||||||||||
| 214 | # }; | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | foreach my $elem (@$array) { | |||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | push @output, $self->serialize( $elem_sig, $elem ); | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | push @output, _tag_stop( $arg->{key} ); | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | return join '', @output; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 8 | ▶ | sub _serialize_simple { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_serialize_simple: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 8 | my ($a, $d) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 8 | ▶ | croak "Undefined data for key $a->{key}\n" if not defined $d; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 8 | my $t = eval { get_xml_type( $a->{type} ) }; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 8 | ▶ | $t or croak "Cannot simple serialize $t: $@"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 8 | return "<$a->{key} xsi:type=\"$t\">$d</$a->{key}>"; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 4 | ▶ | sub _tag_start { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tag_start: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 4 | my ($tname, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 4 | return "<$tname $attr>"; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 4 | ▶ | sub _tag_stop { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tag_stop: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 4 | my ($tname) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 4 | return "</$tname>"; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 9 | ▶ | sub get_xml_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_xml_type: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 9 | my $t = shift; | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 9 | ▶ | return 'xsd:'.$t if ( $t eq 'int' or $t eq 'string' or $t eq 'boolean' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$t eq "int" or $t eq "string" or $t eq "boolean"
$t eq "int" or $t eq "string"
MC/DC0%0/3
$t eq "int" or $t eq "string" or $t eq "boolean"
$t eq "int"
$t eq "string"
$t eq "boolean"
Truth table75%3/4
A or B or C
A= $t eq "int"B= $t eq "string"C= $t eq "boolean"
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | croak "Unknown type: $t"; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ▶ | sub serialize_boolean { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize_boolean: called CC=5 SCAR=20.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | my ($self, $arg, $d) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | if ( ! $d || $d =~ m/^false$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not $d or $d =~ /^false$/i
MC/DC0%0/2
not $d or $d =~ /^false$/i
not $d
$d =~ /^false$/i
Truth table33%1/3
not(A) or B
A= not $dB= $d =~ /^false$/i
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $d = 'false'; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | ▶ | elsif ( $d =~ m/^true$/i || $d ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$d =~ /^true$/i or $d
MC/DC0%0/2
$d =~ /^true$/i or $d
$d =~ /^true$/i
$d
Truth table33%1/3
A or B
A= $d =~ /^true$/iB= $d
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | $d = 'true'; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | return _serialize_simple( $arg, $d ); | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 3 | ▶ | sub serialize_int { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize_int: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | my ($self, $arg, $d) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 3 | ▶ | if ( not $d =~ m/^[0-9]+$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | croak "$arg->{key} is not integer"; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 3 | return _serialize_simple( $arg, $d ); | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 4 | ▶ | sub serialize_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 4 | my ($self, $arg, $d) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 4 | return _serialize_simple( $arg, escape_xml( $d ) ); | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 4 | ▶ | sub escape_xml { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape_xml: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | $_ = shift; | |||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | ▶ | return $_ unless $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 4 | s/&/&/xgs; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | s/</</xgs; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | s/>/>/xgs; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | s/\"/"/xgs; | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 4 | return $_; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||