| 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::SOAP::Client; | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | $VERSION = '3.27'; | |||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
$args{'kind'} || $rr
$args{'kind'}
$rr
Truth table33%1/3
A || B
A= $args{'kind'}B= $rr
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | $kind eq $rr || $kind eq 'one-way' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$kind eq $rr or $kind eq "one-way"
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"
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | my $decode = $args{decode} | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | or error __x"decode for client {name} required", name => $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | my $transport = $args{transport} | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | or error __x"transport for client {name} required", name => $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | if(ref $transport eq 'CODE') { ; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
ref $transport || $transport
ref $transport
$transport
Truth table0%0/3
A || B
A= ref $transportB= $transport
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | , name => $name, type => 'XML::Compile::Transport::SOAPHTTP' | ||||||||||||||||||||||||||||||||||||||||||
| 56 | , is => (ref $transport || $transport); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | my $output_handler = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | my ($ans, $trace, $xops) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=33.1
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | wantarray or return | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | UNIVERSAL::isa($ans, 'XML::LibXML::Node') ? $decode->($ans) : $ans; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if(UNIVERSAL::isa($ans, 'XML::LibXML::Node')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | { $ans = try { $decode->($ans) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if($@) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
wantarray or not $xops or not keys %$xops
wantarray or not $xops
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | #------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||