| 1 | # Copyrights 2009-2018 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.02. | ||||||||||||||||||||||||||||
| 5 | # This code is part of distribution XML-Compile-SOAP12. Meta-POD processed | ||||||||||||||||||||||||||||
| 6 | # with OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | package XML::Compile::SOAP12; | ||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | $VERSION = '3.06'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use base 'XML::Compile::SOAP'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Log::Report 'xml-compile-soap12', syntax => 'SHORT'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use XML::Compile::Util qw/pack_type unpack_type XMLNS type_of_node/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use XML::Compile::SOAP::Util qw/WSDL11SOAP12/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use XML::Compile::SOAP12::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use XML::Compile::SOAP12::Operation; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use File::Glob qw(bsd_glob); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | my %roles = | |||||||||||||||||||||||||||
| 29 | ( NEXT => SOAP12NEXT | ||||||||||||||||||||||||||||
| 30 | , NONE => SOAP12NONE | ||||||||||||||||||||||||||||
| 31 | , ULTIMATE => SOAP12ULTIMATE | ||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | 1 | my %rev_roles = reverse %roles; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | __PACKAGE__->register | |||||||||||||||||||||||||||
| 36 | ( WSDL11SOAP12 | ||||||||||||||||||||||||||||
| 37 | , &SOAP12ENV => 'XML::Compile::SOAP12::Operation' | ||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub new($@) | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 0 | (bless {}, $class)->init( {@_} ); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | sub init($) | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 0 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 49 | 0 | $self->_initSOAP12($self->schemas); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub _initSOAP12($) | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | { my ($thing, $schemas) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_initSOAP12: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 54 | 0 | $thing->_initSOAP($schemas); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | return $thing | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if $schemas->{did_init_SOAP12}++; # ugly | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | $schemas->addPrefixes | |||||||||||||||||||||||||||
| 60 | ( env12 => SOAP12ENV # preferred names by spec | ||||||||||||||||||||||||||||
| 61 | , enc12 => SOAP12ENC | ||||||||||||||||||||||||||||
| 62 | , rpc12 => SOAP12RPC | ||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | (my $dir = __FILE__) =~ s!.pm$!/xsd!; | |||||||||||||||||||||||||||
| 66 | 0 | my @xsd = bsd_glob "$dir/*"; | |||||||||||||||||||||||||||
| 67 | 0 | $schemas->importDefinitions(\@xsd); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | $schemas->importDefinitions(XMLNS, element_form_default => 'qualified' | |||||||||||||||||||||||||||
| 70 | , attribute_form_default => 'qualified'); | ||||||||||||||||||||||||||||
| 71 | 0 | $thing; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | sub _initWSDL11($) | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | { my ($class, $wsdl) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_initWSDL11: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | trace "initialize SOAP12 operations for WSDL11"; | |||||||||||||||||||||||||||
| 78 | 0 | $class->_initSOAP12($wsdl); | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | $wsdl->addPrefixes(soap12 => WSDL11SOAP12); | |||||||||||||||||||||||||||
| 81 | 0 | $wsdl->addKeyRewrite('PREFIXED(soap12)'); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | (my $xsd = __FILE__) =~ s!SOAP12.pm$!WSDL11/xsd/wsdl-soap12.xsd!; | |||||||||||||||||||||||||||
| 84 | 0 | $wsdl->importDefinitions($xsd, element_form_default => 'qualified'); | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | $wsdl->declare(READER => | |||||||||||||||||||||||||||
| 87 | [ "soap12:address", "soap12:operation", "soap12:binding" | ||||||||||||||||||||||||||||
| 88 | , "soap12:body", "soap12:header", "soap12:fault" ]); | ||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub version { 'SOAP12' } | ||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub envelopeNS { SOAP12ENV } | ||||||||||||||||||||||||||
|
Subroutine
envelopeNS: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub envType($) { pack_type SOAP12ENV, $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
envType: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | #--------------- | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | #----------------------------------- | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | sub sender($) | ||||||||||||||||||||||||||||
| 100 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
sender: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | error __x"headerfault does only exist in SOAP1.1" | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if $args->{header_fault}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | $self->SUPER::sender($args); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | sub compileMessage($$) | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | { my ($self, $direction, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
compileMessage: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $args{style} ||= 'document'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"style"} ||= "document"
MC/DC0%0/1
$args{"style"} ||= "document"
$args{"style"}
Truth table0%0/2
A
A= $args{"style"}
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if(ref $args{body} eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | { my @h = @{$args{body}}; | |||||||||||||||||||||||||||
| 115 | 0 | my @parts; | |||||||||||||||||||||||||||
| 116 | 0 | ▶ | push @parts, +{name => shift @h, element => shift @h} while @h; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | $args{body} = +{use => 'literal', parts => \@parts}; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if(ref $args{header} eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | { my @h = @{$args{header}}; | |||||||||||||||||||||||||||
| 122 | 0 | my @o; | |||||||||||||||||||||||||||
| 123 | 0 | ▶ | while(@h) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 0 | { my $part = +{name => shift @h, element => shift @h}; | |||||||||||||||||||||||||||
| 125 | 0 | push @o, +{use => 'literal', parts => [$part]}; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | 0 | $args{header} = \@o; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | my $f = $args{faults}; | |||||||||||||||||||||||||||
| 131 | 0 | ▶ | if(ref $f eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 0 | { $args{faults} = +{}; | |||||||||||||||||||||||||||
| 133 | 0 | my @f = @$f; | |||||||||||||||||||||||||||
| 134 | 0 | ▶ | while(@f) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 0 | { my $name = shift @f; | |||||||||||||||||||||||||||
| 136 | 0 | my $part = +{name => $name, element => shift @f}; | |||||||||||||||||||||||||||
| 137 | 0 | $args{faults}{$name} = +{use => 'literal', part => $part}; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | $self->SUPER::compileMessage($direction, %args); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | #------------------------------------------------ | ||||||||||||||||||||||||||||
| 145 | # Sender | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | sub _sender(@) | ||||||||||||||||||||||||||||
| 148 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_sender: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | ### merge info into headers | ||||||||||||||||||||||||||||
| 151 | # do not destroy original of args | ||||||||||||||||||||||||||||
| 152 | 0 | ▶ | my %destination = @{$args{destination} || []}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'destination'} || []
MC/DC0%0/1
$args{'destination'} || []
$args{'destination'}
Truth table0%0/2
A
A= $args{'destination'}
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | my $understand = $args{mustUnderstand}; | |||||||||||||||||||||||||||
| 155 | 0 | ▶ | my %understand = map +($_ => 1), | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 156 | ref $understand eq 'ARRAY' ? @$understand | ||||||||||||||||||||||||||||
| 157 | : defined $understand ? $understand : (); | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | ▶ | foreach my $h ( @{$args{header} || []} ) | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'header'} || []
MC/DC0%0/1
$args{'header'} || []
$args{'header'}
Truth table0%0/2
A
A= $args{'header'}
| |||||||||||||||||||||||||||||
| 160 | 0 | { my $part = $h->{parts}[0]; | |||||||||||||||||||||||||||
| 161 | 0 | my $label = $part->{name}; | |||||||||||||||||||||||||||
| 162 | 0 | ▶ | $part->{mustUnderstand} ||= delete $understand{$label}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$part->{"mustUnderstand"} ||= delete $understand{$label}
MC/DC0%0/2
$part->{"mustUnderstand"} ||= delete $understand{$label}
$part->{"mustUnderstand"}
delete $understand{$label}
Truth table0%0/3
A ||= B
A= $part->{"mustUnderstand"}B= delete $understand{$label}
| |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $part->{destination} ||= delete $destination{$label}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$part->{"destination"} ||= delete $destination{$label}
MC/DC0%0/2
$part->{"destination"} ||= delete $destination{$label}
$part->{"destination"}
delete $destination{$label}
Truth table0%0/3
A ||= B
A= $part->{"destination"}B= delete $destination{$label}
| |||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if(keys %understand) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 0 | { error __x"mustUnderstand for unknown header {headers}" | |||||||||||||||||||||||||||
| 168 | , headers => [keys %understand]; | ||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if(keys %destination) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | { error __x"destination for unknown header {headers}" | |||||||||||||||||||||||||||
| 173 | , headers => [keys %destination]; | ||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # faults are always possible | ||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my @bparts = @{$args{body}{parts} || []}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'body'}{'parts'} || []
MC/DC0%0/1
$args{'body'}{'parts'} || []
$args{'body'}{'parts'}
Truth table0%0/2
A
A= $args{'body'}{'parts'}
| |||||||||||||||||||||||||||||
| 178 | my $w = $self->schemas->writer('env12:Fault' | ||||||||||||||||||||||||||||
| 179 | 0 | ▶ | , include_namespaces => sub {$_[0] ne SOAP12ENV && $_[2]} | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 0 | ); | |||||||||||||||||||||||||||
| 181 | 0 | push @bparts, | |||||||||||||||||||||||||||
| 182 | { name => 'Fault' | ||||||||||||||||||||||||||||
| 183 | , element => pack_type(SOAP12ENV, 'Fault') | ||||||||||||||||||||||||||||
| 184 | , writer => $w | ||||||||||||||||||||||||||||
| 185 | }; | ||||||||||||||||||||||||||||
| 186 | 0 | local $args{body}{parts} = \@bparts; | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 0 | $self->SUPER::_sender(%args); | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | sub _writer_header($) | ||||||||||||||||||||||||||||
| 192 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_writer_header: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||
| 193 | 0 | my ($rules, $hlabels) = $self->SUPER::_writer_header($args); | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 0 | my $header = $args->{header}; | |||||||||||||||||||||||||||
| 196 | 0 | my @rules; | |||||||||||||||||||||||||||
| 197 | 0 | ▶ | foreach my $h (@{$header || []}) | ||||||||||||||||||||||||||
|
Condition0%0/2
$header || []
MC/DC0%0/1
$header || []
$header
Truth table0%0/2
A
A= $header
| |||||||||||||||||||||||||||||
| 198 | 0 | { my $part = $h->{parts}[0]; | |||||||||||||||||||||||||||
| 199 | 0 | my $label = $part->{name}; | |||||||||||||||||||||||||||
| 200 | 0 | ▶ | $label eq shift @$rules or panic; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | 0 | my $code = shift @$rules; | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | my $understand | ||||||||||||||||||||||||||||
| 204 | = $part->{mustUnderstand} ? 'true' | ||||||||||||||||||||||||||||
| 205 | 0 | ▶ | : defined $part->{mustUnderstand} ? 'false' # explicit | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 206 | : undef; | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | my $actor = $part->{destination}; | |||||||||||||||||||||||||||
| 209 | 0 | ▶ | if(ref $actor eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 210 | 0 | { $actor = join ' ', map $self->roleURI($_), @$actor } | |||||||||||||||||||||||||||
| 211 | elsif(defined $actor) | ||||||||||||||||||||||||||||
| 212 | 0 | { $actor =~ s/\b(\S+)\b/$self->roleURI($1)/ge } | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 0 | my $envpref = $self->schemas->prefixFor(SOAP12ENV); | |||||||||||||||||||||||||||
| 215 | my $wcode = $understand || $actor | ||||||||||||||||||||||||||||
| 216 | ? sub | ||||||||||||||||||||||||||||
| 217 | 0 | ▶ | { my ($doc, $v) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 218 | 0 | my $xml = $code->($doc, $v); | |||||||||||||||||||||||||||
| 219 | 0 | ▶ | $xml->setAttribute("$envpref:mustUnderstand" => 'true') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | if defined $understand; | ||||||||||||||||||||||||||||
| 221 | 0 | ▶ | $xml->setAttribute("$envpref:actor" => $actor) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | if $actor; | ||||||||||||||||||||||||||||
| 223 | 0 | $xml; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | 0 | ▶ | : $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$understand or $actor
MC/DC0%0/2
$understand or $actor
$understand
$actor
Truth table0%0/3
A or B
A= $understandB= $actor
| |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | push @rules, $label => $wcode; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | (\@rules, $hlabels); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | sub _writer_faults($) | ||||||||||||||||||||||||||||
| 234 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_writer_faults: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 235 | 0 | ▶ | my $faults = $args->{faults} ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"faults"} ||= {}
MC/DC0%0/1
$args->{"faults"} ||= {}
$args->{"faults"}
Truth table0%0/2
A
A= $args->{"faults"}
| |||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | my (@rules, @flabels); | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | # Include all namespaces in Fault, because we have no idea which namespace | ||||||||||||||||||||||||||||
| 240 | # is used for the error code. It automatically defines everything | ||||||||||||||||||||||||||||
| 241 | # which may be used in the detail block. | ||||||||||||||||||||||||||||
| 242 | my $wrfault = $self->_writer('env12:Fault' | ||||||||||||||||||||||||||||
| 243 | 0 | ▶ | , include_namespaces => sub {$_[0] ne SOAP12ENV}); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | while(my ($name, $fault) = each %$faults) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 0 | { my $part = $fault->{part}; | |||||||||||||||||||||||||||
| 247 | 0 | my ($label, $type) = ($part->{name}, $part->{element}); | |||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | # spec says: details ALWAYS namespace qualified! | ||||||||||||||||||||||||||||
| 250 | my $details = $self->_writer($type, elements_qualified => 'TOP' | ||||||||||||||||||||||||||||
| 251 | 0 | ▶ | , include_namespaces => sub {$_[0] ne SOAP12ENV && $_[2]}); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | my $code = sub | ||||||||||||||||||||||||||||
| 254 | 0 | ▶ | { my ($doc, $data) = (shift, shift); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 255 | 0 | my %copy = %$data; | |||||||||||||||||||||||||||
| 256 | 0 | ▶ | $copy{Role} ||= $self->roleURI($copy{faultactor}); | ||||||||||||||||||||||||||
|
Condition0%0/3
$copy{"Role"} ||= $self->roleURI($copy{"faultactor"})
MC/DC0%0/2
$copy{"Role"} ||= $self->roleURI($copy{"faultactor"})
$copy{"Role"}
$self->roleURI($copy{"faultactor"})
Truth table0%0/3
A ||= B
A= $copy{"Role"}B= $self->roleURI($copy{"faultactor"})
| |||||||||||||||||||||||||||||
| 257 | 0 | ▶ | my $det = delete $copy{Detail} || delete $copy{detail}; | ||||||||||||||||||||||||||
|
Condition0%0/3
delete $copy{'Detail'} || delete $copy{'detail'}
MC/DC0%0/2
delete $copy{'Detail'} || delete $copy{'detail'}
delete $copy{'Detail'}
delete $copy{'detail'}
Truth table0%0/3
A || B
A= delete $copy{'Detail'}B= delete $copy{'detail'}
| |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my @det = !defined $det ? () : ref $det eq 'ARRAY' ? @$det : $det; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 259 | 0 | $copy{Detail}{$type} = [ map $details->($doc, $_), @det ]; | |||||||||||||||||||||||||||
| 260 | 0 | $wrfault->($doc, \%copy); | |||||||||||||||||||||||||||
| 261 | 0 | }; | |||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | push @rules, $name => $code; | |||||||||||||||||||||||||||
| 264 | 0 | push @flabels, $name; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | (\@rules, \@flabels); | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | ########## | ||||||||||||||||||||||||||||
| 271 | # Receiver | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | sub _reader_fault_reader() | ||||||||||||||||||||||||||||
| 274 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_reader_fault_reader: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | # Nasty, nasty: the spec requires name-space qualified on details, | ||||||||||||||||||||||||||||
| 277 | # even when the schema does not specify that. | ||||||||||||||||||||||||||||
| 278 | 0 | my $schemas = $self->schemas; | |||||||||||||||||||||||||||
| 279 | 0 | ▶ | my $x = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 280 | 0 | my ($xml, $reader, $path, $tag, $r) = @_; | |||||||||||||||||||||||||||
| 281 | 0 | my @childs = grep $_->isa('XML::LibXML::Element'), $xml->childNodes; | |||||||||||||||||||||||||||
| 282 | 0 | ▶ | @childs or return (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | my %h; | |||||||||||||||||||||||||||
| 285 | 0 | foreach my $node (@childs) | |||||||||||||||||||||||||||
| 286 | 0 | { my $type = type_of_node($node); | |||||||||||||||||||||||||||
| 287 | 0 | push @{$h{_ELEMENT_ORDER}}, $type; | |||||||||||||||||||||||||||
| 288 | 0 | $h{$type} = $schemas->reader($type, elements_qualified=>'TOP') | |||||||||||||||||||||||||||
| 289 | ->($node); | ||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | 0 | ($tag => \%h); | |||||||||||||||||||||||||||
| 292 | 0 | }; | |||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | [ Fault => pack_type(SOAP12ENV, 'Fault') | |||||||||||||||||||||||||||
| 295 | , $self->schemas->reader('env12:Fault' | ||||||||||||||||||||||||||||
| 296 | , hooks => { type => 'env12:detail', replace => $x } ) | ||||||||||||||||||||||||||||
| 297 | ]; | ||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | sub _reader_faults($$) | ||||||||||||||||||||||||||||
| 301 | 0 | ▶ | { my ($self, $args, $faults) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_reader_faults: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 0 | my %names; | |||||||||||||||||||||||||||
| 304 | 0 | ▶ | while(my ($name, $def) = each %$faults) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 0 | { $names{$def->{part}{element}} = $name; | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | sub | ||||||||||||||||||||||||||||
| 309 | 0 | ▶ | { my $data = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||
| 310 | 0 | ▶ | my $faults = $data->{Fault} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | #use Data::Dumper; | ||||||||||||||||||||||||||||
| 313 | #warn Dumper $data; | ||||||||||||||||||||||||||||
| 314 | 0 | my $code = $faults->{Code}; | |||||||||||||||||||||||||||
| 315 | 0 | my ($code_ns, $code_err) = unpack_type $code->{Value}; | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 0 | my @subcode; | |||||||||||||||||||||||||||
| 318 | 0 | ▶ | for(my $sc = $code->{Subcode}; $sc; $sc = $sc->{Subcode}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 0 | { push @subcode, $sc->{Value}; | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | my %nice = | ||||||||||||||||||||||||||||
| 323 | ( code => ($subcode[0] || $code_err) | ||||||||||||||||||||||||||||
| 324 | , class => [ $code_ns, $code_err, @subcode ] | ||||||||||||||||||||||||||||
| 325 | , reason => $faults->{Reason}{Text}[0]{_} | ||||||||||||||||||||||||||||
| 326 | 0 | ▶ | ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$subcode[0] || $code_err
MC/DC0%0/2
$subcode[0] || $code_err
$subcode[0]
$code_err
Truth table0%0/3
A || B
A= $subcode[0]B= $code_err
| |||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | $nice{role} = $self->roleAbbreviation($faults->{Role}) | ||||||||||||||||||||||||||||
| 329 | 0 | ▶ | if $faults->{Role}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 0 | my $details = $faults->{Detail}; | |||||||||||||||||||||||||||
| 332 | 0 | ▶ | my $dettype = $details ? delete $details->{_ELEMENT_ORDER} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | #XXX MO may need more work | ||||||||||||||||||||||||||||
| 335 | 0 | my $name; | |||||||||||||||||||||||||||
| 336 | 0 | ▶ | if(!$details) { $name = 'error' } | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 337 | ▶ | elsif(@$dettype && $names{$dettype->[0]}) | |||||||||||||||||||||||||||
|
Condition0%0/3
@$dettype and $names{$dettype->[0]}
MC/DC0%0/2
@$dettype and $names{$dettype->[0]}
@$dettype
$names{$dettype->[0]}
Truth table0%0/3
A and B
A= @$dettypeB= $names{$dettype->[0]}
| |||||||||||||||||||||||||||||
| 338 | { # fault named in WSDL | ||||||||||||||||||||||||||||
| 339 | 0 | $name = $names{$dettype->[0]}; | |||||||||||||||||||||||||||
| 340 | 0 | ▶ | if(keys %$details==1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 0 | { my (undef, $v) = %$details; | |||||||||||||||||||||||||||
| 342 | 0 | ▶ | if(ref $v eq 'HASH') { @nice{keys %$v} = values %$v } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | 0 | else { $nice{details} = $v } | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | elsif(keys %$details==1) | ||||||||||||||||||||||||||||
| 347 | { # simple generic fault, not in WSDL. Maybe internal server error | ||||||||||||||||||||||||||||
| 348 | 0 | ($name) = keys %$details; | |||||||||||||||||||||||||||
| 349 | 0 | my $v = $details->{$name}; | |||||||||||||||||||||||||||
| 350 | 0 | ▶ | my @v = ref $v eq 'ARRAY' ? @$v : $v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 0 | ▶ | my @r = map { UNIVERSAL::isa($_, 'XML::LibXML::Node') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 352 | ? $_->textContent : $_} @v; | ||||||||||||||||||||||||||||
| 353 | 0 | ▶ | $nice{$name} = @r==1 ? $r[0] : \@r; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | else | ||||||||||||||||||||||||||||
| 356 | { # unknown complex generic error | ||||||||||||||||||||||||||||
| 357 | 0 | $name = 'generic'; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 0 | $data->{$name} = \%nice; | |||||||||||||||||||||||||||
| 361 | 0 | $faults->{_NAME} = $name; | |||||||||||||||||||||||||||
| 362 | 0 | $data; | |||||||||||||||||||||||||||
| 363 | 0 | }; | |||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | sub replyMustUnderstandFault($) | ||||||||||||||||||||||||||||
| 367 | 0 | ▶ | { my ($self, $type) = @_; | ||||||||||||||||||||||||||
|
Subroutine
replyMustUnderstandFault: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 0 | +{ Fault => | |||||||||||||||||||||||||||
| 370 | { Code => {Value => pack_type(SOAP12ENV, 'MustUnderstand') } | ||||||||||||||||||||||||||||
| 371 | , Reason => {Text => {lang => 'en', _ => "SOAP mustUnderstand $type"}} | ||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | }; | ||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 0 | ▶ | sub roleURI($) { $roles{$_[1]} || $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
roleURI: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | 0 | ▶ | sub roleAbbreviation($) { $rev_roles{$_[1]} || $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
roleAbbreviation: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 1 | 1; | |||||||||||||||||||||||||||