lib/XML/Compile/SOAP/Client.pm

filter: Statementstmt 64.7% 44 / 68 Branchbran 31.5% 12 / 38 Conditioncond 26.6% 4 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 66.6% 10 / 15 Podpod 33.3% 1 / 3 totaltotal 47.9% 71 / 148 CC 25 SCAR 29.8
CC
25
Cov
50%
compileClient
40.0
__ANON__
27.3
__ANON__
20.0
CRAP 19.6
« lib/XML/Compile/Transport/SOAPHTTP.pm ↑ Summary lib/XML/Compile/SOAP.pm »
1 # Copyrights 2007-2022 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.03.
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::SOAP::Client;
10 7 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 $VERSION = '3.28';
12  
13  
14 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 7 ▶use Log::Report 'xml-compile-soap';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 7 ▶use XML::Compile::Util qw/unpack_type/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 7 ▶use XML::Compile::SOAP::Trace;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 7 ▶use Time::HiRes qw/time/;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23  
24 0 ▶sub new(@) { panic __PACKAGE__." only secundary in multiple inheritance" }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
25 0 ▶sub init($) { shift }
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
26  
27 #--------------
28  
29 7 my $rr = 'request-response';
30  
31 sub compileClient(@)
32 1 ▶{ my ($self, %args) = @_;
Subroutine compileClient: called CC=11 SCAR=36.9
Pod documented
33  
34 1 my $name = $args{name};
35 1 ▶ my $kind = $args{kind} || $rr;
Condition33%1/3
$args{'kind'} || $rr
l!l&&r!l&&!r
010
MC/DC0%0/2
$args{'kind'} || $rr
$args{'kind'} $rr
Truth table33%1/3
A || B
A= $args{'kind'}B= $rr
ABresult
1X1
011
000
36 1 ▶ $kind eq $rr || $kind eq 'one-way'
Branch: 1 branch
BranchTrueFalseTotal
$kind eq $rr or $kind eq "one-way" or &error(&__x("operation direction `{kind}' not supported for {name}", "rr", $rr, "kind", $kind, "name", $name)) 1 0 1
Condition33%1/3
$kind eq $rr or $kind eq "one-way"
l!l&&r!l&&!r
100
MC/DC0%0/2
$kind eq $rr or $kind eq "one-way"
$kind eq $rr $kind eq "one-way"
Truth table33%1/3
A or B
A= $kind eq $rrB= $kind eq "one-way"
ABresult
1X1
011
000
37 or error __x"operation direction `{kind}' not supported for {name}"
38 , rr => $rr, kind => $kind, name => $name;
39  
40 my $encode = $args{encode}
41 1 ▶ or error __x"encode for client {name} required", name => $name;
Branch: 1 branch
BranchTrueFalseTotal
my $encode = $args{"encode"} or &error(&__x("encode for client {name} required", "name", $name)) 1 0 1
42  
43 my $decode = $args{decode}
44 1 ▶ or error __x"decode for client {name} required", name => $name;
Branch: 1 branch
BranchTrueFalseTotal
my $decode = $args{"decode"} or &error(&__x("decode for client {name} required", "name", $name)) 1 0 1
45  
46 my $transport = $args{transport}
47 1 ▶ or error __x"transport for client {name} required", name => $name;
Branch: 1 branch
BranchTrueFalseTotal
my $transport = $args{"transport"} or &error(&__x("transport for client {name} required", "name", $name)) 1 0 1
48  
49 1 ▶ if(ref $transport eq 'CODE') { ; }
Branch: 2 branches
BranchTrueFalseTotal
if (ref $transport eq 'CODE') { } 1 0 1
elsif (UNIVERSAL::isa($transport, 'XML::Compile::Transport::SOAPHTTP')) { } 0 0 0
50 elsif(UNIVERSAL::isa($transport, 'XML::Compile::Transport::SOAPHTTP'))
51 0 { $transport = $transport->compileClient(soap => $args{soap});
52 }
53 else
54 0 ▶ { error __x"transport for client {name} is code ref or {type} object, not {is}"
Condition0%0/3
ref $transport || $transport
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $transport || $transport
ref $transport $transport
Truth table0%0/3
A || B
A= ref $transportB= $transport
ABresult
1X1
011
000
55 , name => $name, type => 'XML::Compile::Transport::SOAPHTTP'
56 , is => (ref $transport || $transport);
57 }
58  
59 1 ▶ my $output_handler = sub {
Subroutine __ANON__: called CC=6 SCAR=33.1
60 1 my ($ans, $trace, $xops) = @_;
61 wantarray or return
62 1 ▶ UNIVERSAL::isa($ans, 'XML::LibXML::Node') ? $decode->($ans) : $ans;
Branch: 2 branches
BranchTrueFalseTotal
wantarray or return UNIVERSAL::isa($ans, "XML::LibXML::Node") ? &$decode($ans) : $ans 0 1 1
UNIVERSAL::isa($ans, 'XML::LibXML::Node') ? : 1 0 1
63  
64 0 ▶ if(UNIVERSAL::isa($ans, 'XML::LibXML::Node'))
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($ans, 'XML::LibXML::Node')) { } 0 0 0
65 0 ▶ { $ans = try { $decode->($ans) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
66 0 ▶ if($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
67 0 { $trace->{decode_errors} = $@;
68 0 my $fatal = $@->wasFatal;
69 0 $trace->{errors} = [$fatal];
70 0 $fatal->message($fatal->message->concat('decode error: ', 1));
71 }
72  
73 0 my $end = time;
74 0 $trace->{decode_elapse} = $end - $trace->{transport_end};
75 0 $trace->{elapse} = $end - $trace->{start};
76 }
77 else
78 { $trace->{elapse} = $trace->{transport_end} - $trace->{start}
79 0 ▶ if defined $trace->{transport_end};
Branch: 1 branch
BranchTrueFalseTotal
if defined $trace->{"transport_end"} 0 0 0
80 }
81 0 ($ans, XML::Compile::SOAP::Trace->new($trace), $xops);
82 1 };
83  
84 $args{async}
85 ? sub # Asynchronous call, f.i. X::C::Transfer::SOAPHTTP::AnyEvent
86 0 ▶ { my ($data, $charset)
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 2 branches
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], 'HASH') ? : 0 0 0
@_ % 2 == 0 ? : 0 0 0
87 = UNIVERSAL::isa($_[0], 'HASH') ? @_
88 : @_%2==0 ? ({@_}, undef)
89 : error __x"operation `{name}' called with odd length parameter list"
90 , name => $name;
91  
92 my $callback = delete $data->{_callback}
93 0 ▶ or error __x"operation `{name}' is async, so requires _callback";
Branch: 1 branch
BranchTrueFalseTotal
my $callback = delete $data->{"_callback"} or &error(&__x("operation `{name}' is async, so requires _callback")) 0 0 0
94  
95 0 my $trace = {start => time};
96 0 my ($req, $mtom) = $encode->($data, $charset);
97 0 $trace->{encode_elapse} = time - $trace->{start};
98  
99 $transport->($req, $trace, $mtom
100 0 ▶ , sub { $callback->($output_handler->(@_)) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
101 0 );
102 }
103 : sub # Synchronous call, f.i. XML::Compile::Transfer::SOAPHTTP
104 1 ▶ { my ($data, $charset)
Subroutine __ANON__: called CC=7 SCAR=22.4
Branch: 2 branches
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], 'HASH') ? : 0 1 1
@_ % 2 == 0 ? : 1 0 1
105 = UNIVERSAL::isa($_[0], 'HASH') ? @_
106 : @_%2==0 ? ({@_}, undef)
107 : panic(__x"operation `{name}' called with odd length parameter list"
108 , name => $name);
109  
110 $data->{_callback}
111 1 ▶ and error __x"operation `{name}' called with _callback, but "
Branch: 1 branch
BranchTrueFalseTotal
$data->{"_callback"} and &error(&__x("operation `{name}' called with _callback, but compiled without async flag", "name", $name)) 0 1 1
112 . "compiled without async flag", name => $name;
113  
114 1 my $trace = {start => time};
115 1 my ($req, $mtom) = $encode->($data, $charset);
116 1 my ($ans, $xops) = $transport->($req, $trace, $mtom);
117 1 ▶ wantarray || !$xops || ! keys %$xops
Branch: 1 branch
BranchTrueFalseTotal
wantarray or not $xops or not keys %$xops or &warning("loosing received XOPs") 1 0 1
Condition33%2/6
wantarray or not $xops or not keys %$xops
l!l&&r!l&&!r
010
wantarray or not $xops
l!l&&r!l&&!r
001
MC/DC0%0/3
wantarray or not $xops or not keys %$xops
wantarray not $xops not keys %$xops
Truth table25%1/4
A or not(B) or not(C)
A= wantarrayB= not $xopsC= not keys %$xops
ABCresult
1XX1
01X1
0011
0000
118 or warning "loosing received XOPs";
119  
120 1 $trace->{encode_elapse} = $trace->{transport_start} - $trace->{start};
121 1 $output_handler->($ans, $trace, $xops);
122 1 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$args{'async'} ? : 0 1 1
123 }
124  
125 #------------------------------------------------
126  
127  
128 7 1;
« lib/XML/Compile/Transport/SOAPHTTP.pm ↑ Summary lib/XML/Compile/SOAP.pm »