| 1 | # Copyrights 2007-2021 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-SOAP. 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::SOAP11; | ||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 7 | $VERSION = '3.27'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use base 'XML::Compile::SOAP'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 7 | ▶ | use Log::Report 'xml-compile-soap'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 7 | ▶ | use XML::Compile::SOAP::Util qw/:soap11/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 7 | ▶ | use XML::Compile::Util qw/pack_type unpack_type type_of_node/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # publish interface to WSDL | ||||||||||||||||||||||||||||
| 24 | 7 | ▶ | use XML::Compile::SOAP11::Operation (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 7 | __PACKAGE__->register | |||||||||||||||||||||||||||
| 27 | ( WSDL11SOAP | ||||||||||||||||||||||||||||
| 28 | , &SOAP11ENV => 'XML::Compile::SOAP11::Operation' | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | sub new($@) | ||||||||||||||||||||||||||||
| 33 | 6 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 6 | ▶ | $class ne __PACKAGE__ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | or error __x"only instantiate a SOAP11::Client or ::Server"; | ||||||||||||||||||||||||||||
| 36 | 6 | $class->SUPER::new(@_); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | sub init($) | ||||||||||||||||||||||||||||
| 40 | 6 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 6 | ▶ | $args->{media_type} ||= 'text/xml'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"media_type"} ||= "text/xml"
MC/DC0%0/1
$args->{"media_type"} ||= "text/xml"
$args->{"media_type"}
Truth table50%1/2
A
A= $args->{"media_type"}
| |||||||||||||||||||||||||||||
| 42 | 6 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 43 | 6 | $self->_initSOAP11($self->schemas); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | sub _initSOAP11($) | ||||||||||||||||||||||||||||
| 47 | 6 | ▶ | { my ($self, $schemas) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_initSOAP11: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | return $self | ||||||||||||||||||||||||||||
| 50 | 6 | ▶ | if $schemas->{did_init_SOAP11}++; # ugly | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 6 | $self->_initSOAP($schemas); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 6 | (my $xsddir = __FILE__) =~ s!\.pm$!/xsd!; | |||||||||||||||||||||||||||
| 55 | 6 | $schemas->addPrefixes('SOAP-ENV' => SOAP11ENV); | |||||||||||||||||||||||||||
| 56 | 6 | $schemas->importDefinitions("$xsddir/soap-envelope.xsd"); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 6 | ▶ | $self->_initRpcEnc11($schemas, $xsddir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | if $self->can('_initRpcEnc11'); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 6 | $self; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub _initWSDL11($) | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | { my ($class, $wsdl) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_initWSDL11: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | return $class | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if $wsdl->{did_init_SOAP11_WSDL}++; # ugly | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | trace "initialize SOAP11 for WSDL11"; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | (my $xsddir = __FILE__) =~ s!SOAP11\.pm$!WSDL11/xsd!; | |||||||||||||||||||||||||||
| 73 | 0 | $wsdl->importDefinitions("$xsddir/wsdl-soap.xsd"); | |||||||||||||||||||||||||||
| 74 | 0 | $wsdl->addPrefixes(soap => WSDL11SOAP); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | $wsdl->declare(READER => | |||||||||||||||||||||||||||
| 77 | [ "soap:address", "soap:operation", "soap:binding" | ||||||||||||||||||||||||||||
| 78 | , "soap:body", "soap:header", "soap:fault" ]); | ||||||||||||||||||||||||||||
| 79 | 0 | $class; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub version { 'SOAP11' } | ||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 28 | ▶ | sub envelopeNS { SOAP11ENV } | ||||||||||||||||||||||||||
|
Subroutine
envelopeNS: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 84 | 33 | ▶ | sub envType($) { pack_type SOAP11ENV, $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
envType: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | #----------------------------------- | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | sub compileMessage($$) | ||||||||||||||||||||||||||||
| 90 | 11 | ▶ | { my ($self, $direction, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
compileMessage: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 11 | ▶ | $args{style} ||= 'document'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{"style"} ||= "document"
MC/DC0%0/1
$args{"style"} ||= "document"
$args{"style"}
Truth table50%1/2
A
A= $args{"style"}
| |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 11 | ▶ | if(ref $args{body} eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 8 | { my @h = @{$args{body}}; | |||||||||||||||||||||||||||
| 95 | 8 | my @parts; | |||||||||||||||||||||||||||
| 96 | 8 | ▶ | push @parts, +{name => shift @h, element => shift @h} while @h; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 8 | $args{body} = +{use => 'literal', parts => \@parts}; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 11 | ▶ | if(ref $args{header} eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 4 | { my @h = @{$args{header}}; | |||||||||||||||||||||||||||
| 102 | 4 | my @o; | |||||||||||||||||||||||||||
| 103 | 4 | ▶ | while(@h) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 4 | { my $part = +{name => shift @h, element => shift @h}; | |||||||||||||||||||||||||||
| 105 | 4 | push @o, +{use => 'literal', parts => [$part]}; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 4 | $args{header} = \@o; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 11 | my $f = $args{faults}; | |||||||||||||||||||||||||||
| 111 | 11 | ▶ | if(ref $f eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 2 | { $args{faults} = +{}; | |||||||||||||||||||||||||||
| 113 | 2 | my @f = @$f; | |||||||||||||||||||||||||||
| 114 | 2 | ▶ | while(@f) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 2 | { my $name = shift @f; | |||||||||||||||||||||||||||
| 116 | 2 | my $part = +{name => $name, element => shift @f}; | |||||||||||||||||||||||||||
| 117 | 2 | $args{faults}{$name} = +{use => 'literal', part => $part}; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 11 | $self->SUPER::compileMessage($direction, %args); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | #------------------------------------------------ | ||||||||||||||||||||||||||||
| 125 | # Sender | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | sub _sender(@) | ||||||||||||||||||||||||||||
| 128 | 5 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_sender: called CC=11 SCAR=24.6
| |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | ### merge info into headers | ||||||||||||||||||||||||||||
| 131 | # do not destroy original of args | ||||||||||||||||||||||||||||
| 132 | 5 | ▶ | my %destination = @{$args{destination} || []}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 5 | my $understand = $args{mustUnderstand}; | |||||||||||||||||||||||||||
| 135 | 5 | ▶ | my %understand = map +($_ => 1), | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 136 | ref $understand eq 'ARRAY' ? @$understand | ||||||||||||||||||||||||||||
| 137 | : defined $understand ? $understand : (); | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 5 | ▶ | foreach my $h ( @{$args{header} || []} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 2 | { my $part = $h->{parts}[0]; | |||||||||||||||||||||||||||
| 141 | 2 | my $label = $part->{name}; | |||||||||||||||||||||||||||
| 142 | 2 | ▶ | $part->{mustUnderstand} ||= delete $understand{$label}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$part->{"mustUnderstand"} ||= delete $understand{$label}
MC/DC0%0/2
$part->{"mustUnderstand"} ||= delete $understand{$label}
$part->{"mustUnderstand"}
delete $understand{$label}
Truth table33%1/3
A ||= B
A= $part->{"mustUnderstand"}B= delete $understand{$label}
| |||||||||||||||||||||||||||||
| 143 | 2 | ▶ | $part->{destination} ||= delete $destination{$label}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$part->{"destination"} ||= delete $destination{$label}
MC/DC50%1/2
$part->{"destination"} ||= delete $destination{$label}
$part->{"destination"}
delete $destination{$label}
Truth table66%2/3
A ||= B
A= $part->{"destination"}B= delete $destination{$label}
| |||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 5 | ▶ | if(keys %understand) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | { error __x"mustUnderstand for unknown header {headers}" | |||||||||||||||||||||||||||
| 148 | , headers => [keys %understand]; | ||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 5 | ▶ | if(keys %destination) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | { error __x"destination for unknown header {headers}" | |||||||||||||||||||||||||||
| 153 | , headers => [keys %destination]; | ||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | # faults are always possible | ||||||||||||||||||||||||||||
| 157 | 5 | ▶ | my @bparts = @{$args{body}{parts} || []}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | my $w = $self->schemas->writer('SOAP-ENV:Fault' | ||||||||||||||||||||||||||||
| 159 | 20 | ▶ | , include_namespaces => sub {$_[0] ne SOAP11ENV && $_[2]} | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 5 | ); | |||||||||||||||||||||||||||
| 161 | 5 | push @bparts, | |||||||||||||||||||||||||||
| 162 | { name => 'Fault' | ||||||||||||||||||||||||||||
| 163 | , element => pack_type(SOAP11ENV, 'Fault') | ||||||||||||||||||||||||||||
| 164 | , writer => $w | ||||||||||||||||||||||||||||
| 165 | }; | ||||||||||||||||||||||||||||
| 166 | 5 | local $args{body}{parts} = \@bparts; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 5 | $self->SUPER::_sender(%args); | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | sub _writer_header($) | ||||||||||||||||||||||||||||
| 172 | 5 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_writer_header: called CC=10 SCAR=24.0
| |||||||||||||||||||||||||||||
| 173 | 5 | my ($rules, $hlabels) = $self->SUPER::_writer_header($args); | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 5 | my $header = $args->{header}; | |||||||||||||||||||||||||||
| 176 | 5 | my @rules; | |||||||||||||||||||||||||||
| 177 | 5 | ▶ | foreach my $h (@{$header || []}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 2 | { my $part = $h->{parts}[0]; | |||||||||||||||||||||||||||
| 179 | 2 | my $label = $part->{name}; | |||||||||||||||||||||||||||
| 180 | 2 | ▶ | $label eq shift @$rules or panic; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 2 | my $code = shift @$rules; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | # fixed in SOAP12, but SOAP11 only understands numeric boolean values | ||||||||||||||||||||||||||||
| 184 | my $understand | ||||||||||||||||||||||||||||
| 185 | = $part->{mustUnderstand} ? '1' | ||||||||||||||||||||||||||||
| 186 | 2 | ▶ | : defined $part->{mustUnderstand} ? '0' # explicit 0 | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 187 | : undef; | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 2 | my $actor = $part->{destination}; | |||||||||||||||||||||||||||
| 190 | 2 | ▶ | if(ref $actor eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 191 | 0 | { $actor = join ' ', map $self->roleURI($_), @$actor } | |||||||||||||||||||||||||||
| 192 | elsif(defined $actor) | ||||||||||||||||||||||||||||
| 193 | 1 | { $actor =~ s/\b(\S+)\b/$self->roleURI($1)/ge } | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 2 | my $envpref = $self->schemas->prefixFor(SOAP11ENV); | |||||||||||||||||||||||||||
| 196 | my $wcode = $understand || $actor | ||||||||||||||||||||||||||||
| 197 | ? sub | ||||||||||||||||||||||||||||
| 198 | 3 | ▶ | { my ($doc, $v) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 199 | 3 | my $xml = $code->($doc, $v); | |||||||||||||||||||||||||||
| 200 | 3 | ▶ | $xml->setAttribute("$envpref:mustUnderstand" => '1') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | if defined $understand; | ||||||||||||||||||||||||||||
| 202 | 3 | ▶ | $xml->setAttribute("$envpref:actor" => $actor) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | if $actor; | ||||||||||||||||||||||||||||
| 204 | 3 | $xml; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | 2 | ▶ | : $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$understand or $actor
MC/DC0%0/2
$understand or $actor
$understand
$actor
Truth table33%1/3
A or B
A= $understandB= $actor
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 2 | push @rules, $label => $wcode; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 5 | (\@rules, $hlabels); | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | sub _writer_faults($) | ||||||||||||||||||||||||||||
| 215 | 5 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_writer_faults: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 216 | 5 | ▶ | my $faults = $args->{faults} ||= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args->{"faults"} ||= {}
MC/DC100%1/1
$args->{"faults"} ||= {}
$args->{"faults"}
Truth table100%2/2
A
A= $args->{"faults"}
| |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 5 | my (@rules, @flabels); | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | # Include all namespaces in Fault, because we have no idea which namespace | ||||||||||||||||||||||||||||
| 221 | # is used for the error code. It automatically defines everything | ||||||||||||||||||||||||||||
| 222 | # which may be used in the detail block. | ||||||||||||||||||||||||||||
| 223 | my $wrfault = $self->_writer('SOAP-ENV:Fault' | ||||||||||||||||||||||||||||
| 224 | 5 | ▶ | , include_namespaces => sub {$_[0] ne SOAP11ENV}); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 5 | ▶ | while(my ($name, $fault) = each %$faults) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 1 | { my $part = $fault->{part}; | |||||||||||||||||||||||||||
| 228 | 1 | my ($elem, $details) = $self->_write_one_fault($args, $part); | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | my $code = sub | ||||||||||||||||||||||||||||
| 231 | 1 | ▶ | { my ($doc, $data) = (shift, shift); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||
| 232 | 1 | my %copy = %$data; | |||||||||||||||||||||||||||
| 233 | 1 | $copy{faultactor} = $self->roleURI($copy{faultactor}); | |||||||||||||||||||||||||||
| 234 | 1 | my $det = delete $copy{detail}; | |||||||||||||||||||||||||||
| 235 | 1 | ▶ | my @det = !defined $det ? () : ref $det eq 'ARRAY' ? @$det : $det; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 236 | 1 | $copy{detail}{$elem} = [ map $details->($doc, $_), @det ]; | |||||||||||||||||||||||||||
| 237 | 1 | $wrfault->($doc, \%copy); | |||||||||||||||||||||||||||
| 238 | 1 | }; | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 1 | push @rules, $name => $code; | |||||||||||||||||||||||||||
| 241 | 1 | push @flabels, $name; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 5 | (\@rules, \@flabels); | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | sub _write_one_fault($$) | ||||||||||||||||||||||||||||
| 248 | 1 | ▶ | { my ($self, $args, $part) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_write_one_fault: called CC=5 SCAR=24.5
| |||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | # spec says: details ALWAYS namespace qualified! | ||||||||||||||||||||||||||||
| 251 | 1 | ▶ | if(my $elem = $part->{element}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | { my $writer = $self->{writer} ||= | ||||||||||||||||||||||||||||
| 253 | $self->_writer($elem | ||||||||||||||||||||||||||||
| 254 | 1 | ▶ | , include_namespaces => sub {$_[0] ne SOAP11ENV && $_[2]}); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.4
Branch: 1 branch
Condition33%1/3
$self->{"writer"} ||= $self->_writer($elem, "include_namespaces", sub {
$_[0] ne "http://schemas.xmlsoap.org/soap/envelope/" and $_[2];
}
)
MC/DC0%0/2
$self->{"writer"} ||= $self->_writer($elem, "include_namespaces", sub {
$_[0] ne "http://schemas.xmlsoap.org/soap/envelope/" and $_[2];
}
)
$self->{"writer"}
$self->_writer($elem, "include_namespaces", sub {
$_[0] ne "http://schemas.xmlsoap.org/soap/envelope/" and $_[2];
}
)
Truth table33%1/3
A ||= B
A= $self->{"writer"}B= $self->_writer($elem, "include_namespaces", sub {
$_[0] ne "http://schemas.xmlsoap.org/soap/envelope/" and $_[2];
}
)
| |||||||||||||||||||||||||||||
| 255 | 1 | return ($elem, $writer); | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | if(my $type = $part->{type}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 0 | { my $elem = $part->{name}; | |||||||||||||||||||||||||||
| 260 | my $writer = $part->{writer} ||= $self->schemas->compileType | ||||||||||||||||||||||||||||
| 261 | ( WRITER => $part->{type}, %$args | ||||||||||||||||||||||||||||
| 262 | , element => $part->{name} | ||||||||||||||||||||||||||||
| 263 | 0 | ▶ | , include_namespaces => sub {$_[0] ne SOAP11ENV && $_[2]} | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | ▶ | ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$part->{"writer"} ||= $self->schemas->compileType("WRITER", $part->{"type"}, %$args, "element", $part->{"name"}, "include_namespaces", sub {
$_[0] ne "http://schemas.xmlsoap.org/soap/envelope/" and $_[2];
}
)
MC/DC0%0/2
$part->{"writer"} ||= $self->schemas->compileType("WRITER", $part->{"type"}, %$args, "element", $part->{"name"}, "include_namespaces", sub {
$_[0] ne "http://schemas.xmlsoap.org/soap/envelope/" and $_[2];
}
)
$part->{"writer"}
$self->schemas->compileType("WRITER", $part->{"type"}, %$args, "element", $part->{"name"}, "include_namespaces", sub {
$_[0] ne "http://schemas.xmlsoap.org/soap/envelope/" and $_[2];
}
)
Truth table0%0/3
A ||= B
A= $part->{"writer"}B= $self->schemas->compileType("WRITER", $part->{"type"}, %$args, "element", $part->{"name"}, "include_namespaces", sub {
$_[0] ne "http://schemas.xmlsoap.org/soap/envelope/" and $_[2];
}
)
| |||||||||||||||||||||||||||||
| 265 | 0 | return ($elem, $writer); | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | error __x"fault part {name} has neither `element' nor `type' specified" | ||||||||||||||||||||||||||||
| 269 | 0 | , name => $part->{name}; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | ########## | ||||||||||||||||||||||||||||
| 273 | # Receiver | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | sub _reader_fault_reader() | ||||||||||||||||||||||||||||
| 276 | 6 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_reader_fault_reader: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | # Nasty, nasty: the spec requires name-space qualified on details, | ||||||||||||||||||||||||||||
| 279 | # even when the schema does not specify that. | ||||||||||||||||||||||||||||
| 280 | 6 | my $schemas = $self->schemas; | |||||||||||||||||||||||||||
| 281 | my $x = sub { | ||||||||||||||||||||||||||||
| 282 | 1 | ▶ | my ($xml, $reader, $path, $tag, $r) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 283 | 1 | my @childs = grep $_->isa('XML::LibXML::Element'), $xml->childNodes; | |||||||||||||||||||||||||||
| 284 | 1 | ▶ | @childs or return (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 1 | my %h; | |||||||||||||||||||||||||||
| 287 | 1 | foreach my $node (@childs) | |||||||||||||||||||||||||||
| 288 | 1 | { my $type = type_of_node($node); | |||||||||||||||||||||||||||
| 289 | 1 | push @{$h{_ELEMENT_ORDER}}, $type; | |||||||||||||||||||||||||||
| 290 | 1 | ▶ | my $dec = try { $schemas->reader($type)->($node) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 291 | 1 | ▶ | $h{$type} = $dec // $node; | ||||||||||||||||||||||||||
|
Condition33%1/3
$dec // $node
MC/DC0%0/2
$dec // $node
$dec
$node
Truth table33%1/3
A // B
A= $decB= $node
| |||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | 1 | ($tag => \%h); | |||||||||||||||||||||||||||
| 294 | 6 | }; | |||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 6 | [ Fault => pack_type(SOAP11ENV, 'Fault') | |||||||||||||||||||||||||||
| 297 | , $self->schemas->reader('SOAP-ENV:Fault' | ||||||||||||||||||||||||||||
| 298 | , hooks => { type => 'SOAP-ENV:detail', replace => $x } ) | ||||||||||||||||||||||||||||
| 299 | ]; | ||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | sub _reader_faults($$) | ||||||||||||||||||||||||||||
| 303 | 6 | ▶ | { my ($self, $args, $faults) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_reader_faults: called CC=3 SCAR=12.2
| |||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 6 | my %names; | |||||||||||||||||||||||||||
| 306 | 6 | ▶ | while(my ($name, $def) = each %$faults) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 1 | ▶ | { $names{$def->{part}{element} || $name} = $name; | ||||||||||||||||||||||||||
|
Condition33%1/3
$def->{'part'}{'element'} || $name
MC/DC0%0/2
$def->{'part'}{'element'} || $name
$def->{'part'}{'element'}
$name
Truth table33%1/3
A || B
A= $def->{'part'}{'element'}B= $name
| |||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | sub | ||||||||||||||||||||||||||||
| 311 | 9 | ▶ | { my $data = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=15 SCAR=33.1
| |||||||||||||||||||||||||||||
| 312 | 9 | ▶ | my $faults = $data->{Fault} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 3 | my ($code_ns, $code_err) = unpack_type $faults->{faultcode}; | |||||||||||||||||||||||||||
| 315 | 3 | my ($err, @sub_err) = split /\./, $code_err; | |||||||||||||||||||||||||||
| 316 | 3 | ▶ | $err = 'Receiver' if $err eq 'Server'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 317 | 3 | ▶ | $err = 'Sender' if $err eq 'Client'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | my %nice = | ||||||||||||||||||||||||||||
| 320 | ( code => $faults->{faultcode} | ||||||||||||||||||||||||||||
| 321 | , class => [ $code_ns, $err, @sub_err ] | ||||||||||||||||||||||||||||
| 322 | , reason => $faults->{faultstring} | ||||||||||||||||||||||||||||
| 323 | 3 | ); | |||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | $nice{role} = $self->roleAbbreviation($faults->{faultactor}) | ||||||||||||||||||||||||||||
| 326 | 3 | ▶ | if $faults->{faultactor}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 3 | my $details = $faults->{detail}; | |||||||||||||||||||||||||||
| 329 | 3 | ▶ | my $dettype = $details ? delete $details->{_ELEMENT_ORDER} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 3 | my $name; | |||||||||||||||||||||||||||
| 332 | 3 | ▶ | if(!$details) { $name = 'error' } | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 333 | ▶ | elsif(@$dettype && $names{$dettype->[0]}) | |||||||||||||||||||||||||||
|
Condition33%1/3
@$dettype and $names{$dettype->[0]}
MC/DC0%0/2
@$dettype and $names{$dettype->[0]}
@$dettype
$names{$dettype->[0]}
Truth table33%1/3
A and B
A= @$dettypeB= $names{$dettype->[0]}
| |||||||||||||||||||||||||||||
| 334 | { # fault named in WSDL | ||||||||||||||||||||||||||||
| 335 | 1 | $name = $names{$dettype->[0]}; | |||||||||||||||||||||||||||
| 336 | 1 | ▶ | if(keys %$details==1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 1 | { my (undef, $v) = %$details; | |||||||||||||||||||||||||||
| 338 | 1 | ▶ | if(ref $v eq 'HASH') { @nice{keys %$v} = values %$v } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 0 | else { $nice{details} = $v } | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | elsif(keys %$details==1) | ||||||||||||||||||||||||||||
| 343 | { # simple generic fault, not in WSDL. Maybe internal server error | ||||||||||||||||||||||||||||
| 344 | 0 | ($name) = keys %$details; | |||||||||||||||||||||||||||
| 345 | 0 | my $v = $details->{$name}; | |||||||||||||||||||||||||||
| 346 | 0 | ▶ | my @v = ref $v eq 'ARRAY' ? @$v : $v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | 0 | ▶ | my @r = map { UNIVERSAL::isa($_, 'XML::LibXML::Node') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 348 | ? $_->textContent : $_} @v; | ||||||||||||||||||||||||||||
| 349 | 0 | ▶ | $nice{$name} = @r==1 ? $r[0] : \@r; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | else | ||||||||||||||||||||||||||||
| 352 | { # unknown complex generic error | ||||||||||||||||||||||||||||
| 353 | 0 | $name = 'generic'; | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 3 | $data->{$name} = \%nice; | |||||||||||||||||||||||||||
| 357 | 3 | $faults->{_NAME} = $name; | |||||||||||||||||||||||||||
| 358 | 3 | $data; | |||||||||||||||||||||||||||
| 359 | 6 | }; | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | sub replyMustUnderstandFault($) | ||||||||||||||||||||||||||||
| 363 | 1 | ▶ | { my ($self, $type) = @_; | ||||||||||||||||||||||||||
|
Subroutine
replyMustUnderstandFault: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 1 | +{ Fault => | |||||||||||||||||||||||||||
| 366 | { faultcode => pack_type(SOAP11ENV, 'MustUnderstand') | ||||||||||||||||||||||||||||
| 367 | , faultstring => "SOAP mustUnderstand $type" | ||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | }; | ||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 3 | ▶ | sub roleURI($) { $_[1] && $_[1] eq 'NEXT' ? SOAP11NEXT : $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
roleURI: called CC=3 SCAR=11.1
Pod
documented
Branch: 1 branch
Condition66%2/3
$_[1] and $_[1] eq "NEXT"
MC/DC50%1/2
$_[1] and $_[1] eq "NEXT"
$_[1]
$_[1] eq "NEXT"
Truth table66%2/3
A and B
A= $_[1]B= $_[1] eq "NEXT"
| |||||||||||||||||||||||||||||
| 373 | 1 | ▶ | sub roleAbbreviation($) { $_[1] && $_[1] eq SOAP11NEXT ? 'NEXT' : $_[1] } | ||||||||||||||||||||||||||
|
Subroutine
roleAbbreviation: called CC=3 SCAR=14.2
Pod
documented
Branch: 1 branch
Condition33%1/3
$_[1] and $_[1] eq "http://schemas.xmlsoap.org/soap/actor/next"
MC/DC0%0/2
$_[1] and $_[1] eq "http://schemas.xmlsoap.org/soap/actor/next"
$_[1]
$_[1] eq "http://schemas.xmlsoap.org/soap/actor/next"
Truth table33%1/3
A and B
A= $_[1]B= $_[1] eq "http://schemas.xmlsoap.org/soap/actor/next"
| |||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | #------------------------------------- | ||||||||||||||||||||||||||||
| 376 | # docs of ::SOAP11::Encoding inserted here | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | #------------------------------------- | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | 7 | 1; | |||||||||||||||||||||||||||