lib/XML/Compile/SOAP/Operation.pm

filter: Statementstmt 27.7% 30 / 108 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 26.4% 9 / 34 Podpod 83.3% 20 / 24 totaltotal 26.9% 59 / 219 SCAR 60.2
CC
27
Cov
19%
compileTransporter
132.0
init
110.0
_server_type
56.0
CRAP 412.9
« lib/XML/Compile/SOAP/Trace.pm ↑ Summary blib/lib/XML/Compile/SOAP/Operation.pm »
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::Operation;
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-report-soap';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 7 ▶use XML::Compile::Util qw/pack_type unpack_type/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 7 ▶use XML::Compile::SOAP::Util qw/:wsdl11/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 7 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 7 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 7 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 7 my %servers =
27 ( 'XML::Compile::Daemon' => # my own server implementation
28 { xsddir => 'xcdaemon'
29 , xsds => [ qw(xcdaemon.xsd) ]
30 }
31 # more in XML::Compile::Licensed
32 );
33  
34  
35 0 ▶sub new(@) { my $class = shift; (bless {}, $class)->init( {@_} ) }
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
36  
37 sub init($)
38 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=10 SCAR=47.0
Pod undocumented
39 0 ▶ $self->{kind} = $args->{kind} or panic;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"kind"} = $args->{"kind"} or &panic() 0 0 0
40 0 ▶ $self->{name} = $args->{name} or panic;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"name"} = $args->{"name"} or &panic() 0 0 0
41 0 ▶ $self->{schemas} = $args->{schemas} or panic;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"schemas"} = $args->{"schemas"} or &panic() 0 0 0
42 0 $self->_server_type($args->{server_type});
43  
44 0 $self->{transport} = $args->{transport};
45 0 $self->{action} = $args->{action};
46  
47 0 ▶ my $ep = $args->{endpoints} || [];
Condition0%0/2
$args->{'endpoints'} || []
l!l
00
MC/DC0%0/1
$args->{'endpoints'} || []
$args->{'endpoints'}
Truth table0%0/2
A
A= $args->{'endpoints'}
Aresult
11
00
48 0 ▶ my @ep = ref $ep eq 'ARRAY' ? @$ep : $ep;
Branch: 1 branch
BranchTrueFalseTotal
ref $ep eq 'ARRAY' ? : 0 0 0
49 0 $self->{endpoints} = \@ep;
50  
51 # undocumented, because not for end-user
52 0 ▶ if(my $binding = $args->{binding}) { $self->{bindname} = $binding->{name} }
Branch: 1 branch
BranchTrueFalseTotal
if (my $binding = $args->{"binding"}) 0 0 0
53 0 ▶ if(my $service = $args->{service}) { $self->{servname} = $service->{name} }
Branch: 1 branch
BranchTrueFalseTotal
if (my $service = $args->{"service"}) 0 0 0
54 0 ▶ if(my $port = $args->{serv_port}){ $self->{portname} = $port->{name} }
Branch: 1 branch
BranchTrueFalseTotal
if (my $port = $args->{"serv_port"}) 0 0 0
55 0 ▶ if(my $port_type= $args->{portType}){ $self->{porttypename} = $port_type->{name} }
Branch: 1 branch
BranchTrueFalseTotal
if (my $port_type = $args->{"portType"}) 0 0 0
56  
57 0 $self;
58 }
59  
60 sub registered
61 { # This cannot be resolved via dependencies, because that causes
62 # a dependency cycle which CPAN.pm cannot handle. This method was
63 # always called in <3.00 and moved to ::SOAP in >= 3.00
64 0 ▶ error "You need to upgrade XML::Compile::WSDL11 to at least 3.00";
Subroutine registered: not called CC=1 SCAR=6.9
Pod undocumented
65 }
66  
67 sub _server_type($)
68 0 ▶{ my ($self, $type) = @_;
Subroutine _server_type: not called CC=7 SCAR=40.3
69 0 ▶ $type or return;
Branch: 1 branch
BranchTrueFalseTotal
$type or return 0 0 0
70  
71 0 my $schemas = $self->schemas;
72 0 ▶ return if $schemas->{"did_init_server_$type"}++;
Branch: 1 branch
BranchTrueFalseTotal
if $$schemas{"did_init_server_$type"}++ 0 0 0
73  
74 0 my ($def, $xsddir);
75 0 ▶ if($def = $servers{$type})
Branch: 1 branch
BranchTrueFalseTotal
if ($def = $servers{$type}) { } 0 0 0
76 0 { $xsddir = File::Spec->catdir(dirname(__FILE__), 'xsd', $def->{xsddir});
77 }
78 else
79 0 { eval "require XML::Compile::Licensed";
80 0 ▶ if($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
81 0 { error __x"soap server type `{type}' is not supported (yet); installing XML::Compile::Licensed may help"
82 , type => $type;
83 }
84 0 ▶ ($xsddir, $def) = XML::Compile::Licensed->soapServer($type)
Branch: 1 branch
BranchTrueFalseTotal
($xsddir, $def) = "XML::Compile::Licensed"->soapServer($type) or &error(&__x("soap server type `{type}' is not supported (yet)", "type", $type)) 0 0 0
85 or error __x"soap server type `{type}' is not supported (yet)"
86 , type => $type;
87 }
88  
89 $schemas->importDefinitions(File::Spec->catfile($xsddir, $_))
90 0 for @{$def->{xsds}};
91 }
92  
93 #----------------
94  
95 0 ▶sub schemas() {shift->{schemas}}
Subroutine schemas: not called CC=1 SCAR=6.9
Pod documented
96 0 ▶sub kind() {shift->{kind}}
Subroutine kind: not called CC=1 SCAR=6.9
Pod documented
97 0 ▶sub name() {shift->{name}}
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
98 0 ▶sub style() {shift->{style}}
Subroutine style: not called CC=1 SCAR=6.9
Pod undocumented
99 0 ▶sub transport() {shift->{transport}}
Subroutine transport: not called CC=1 SCAR=6.9
Pod documented
100 0 ▶sub version() {panic}
Subroutine version: not called CC=1 SCAR=6.9
Pod documented
101  
102 0 ▶sub bindingName() {shift->{bindname}}
Subroutine bindingName: not called CC=1 SCAR=6.9
Pod documented
103 0 ▶sub serviceName() {shift->{servname}}
Subroutine serviceName: not called CC=1 SCAR=6.9
Pod documented
104 0 ▶sub portName() {shift->{portname}}
Subroutine portName: not called CC=1 SCAR=6.9
Pod documented
105 0 ▶sub portTypeName(){shift->{porttypename}}
Subroutine portTypeName: not called CC=1 SCAR=6.9
Pod undocumented
106  
107  
108 0 ▶sub soapAction {shift->{action}}
Subroutine soapAction: not called CC=1 SCAR=6.9
Pod documented
109 0 ▶sub action() {shift->{action}} # deprecated
Subroutine action: not called CC=1 SCAR=6.9
Pod documented
110  
111 # wsaAction is implement in XML::Compile::SOAP::WSA
112  
113  
114 0 ▶sub serverClass {panic}
Subroutine serverClass: not called CC=1 SCAR=6.9
Pod documented
115 0 ▶sub clientClass {panic}
Subroutine clientClass: not called CC=1 SCAR=6.9
Pod documented
116  
117  
118 0 ▶sub endPoints() { @{shift->{endpoints}} }
Subroutine endPoints: not called CC=1 SCAR=6.9
Pod documented
119  
120  
121 sub longName()
122 0 ▶{ my $self = shift;
Subroutine longName: not called CC=2 SCAR=17.9
Pod documented
123 0 ▶ ($self->serviceName // '') . '#' . $self->name;
Condition0%0/2
$self->serviceName // ""
l!l
00
MC/DC0%0/1
$self->serviceName // ""
$self->serviceName
Truth table0%0/2
A
A= $self->serviceName
Aresult
11
00
124 }
125  
126 #-------------------------------------------
127  
128  
129 sub compileTransporter(@)
130 0 ▶{ my ($self, %args) = @_;
Subroutine compileTransporter: not called CC=11 SCAR=48.8
Pod documented
131  
132 0 ▶ my $transp = delete $args{transporter} || delete $args{transport};
Condition0%0/3
delete $args{'transporter'} || delete $args{'transport'}
l!l&&r!l&&!r
000
MC/DC0%0/2
delete $args{'transporter'} || delete $args{'transport'}
delete $args{'transporter'} delete $args{'transport'}
Truth table0%0/3
A || B
A= delete $args{'transporter'}B= delete $args{'transport'}
ABresult
1X1
011
000
133 0 ▶ return $transp if ref $transp eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $transp eq "CODE" 0 0 0
134  
135 0 my $proto = $self->transport;
136 0 my @endpoints;
137 0 ▶ if(my $endpoints = $args{endpoint})
Branch: 1 branch
BranchTrueFalseTotal
if (my $endpoints = $args{"endpoint"}) 0 0 0
138 0 ▶ { @endpoints = ref $endpoints eq 'ARRAY' ? @$endpoints : $endpoints;
Branch: 1 branch
BranchTrueFalseTotal
ref $endpoints eq 'ARRAY' ? : 0 0 0
139 }
140 0 ▶ unless(@endpoints)
Branch: 1 branch
BranchTrueFalseTotal
unless (@endpoints) 0 0 0
141 0 { @endpoints = $self->endPoints;
142 0 ▶ if(my $s = $args{server})
Branch: 1 branch
BranchTrueFalseTotal
if (my $s = $args{"server"}) 0 0 0
143 0 { s#^(\w+)://([^/]+)#$1://$s# for @endpoints;
144 }
145 }
146  
147 0 my $id = join ';', sort @endpoints;
148 0 my $send = $self->{transp_cache}{$proto}{$id};
149 0 ▶ return $send if $send;
Branch: 1 branch
BranchTrueFalseTotal
if $send 0 0 0
150  
151 0 ▶ unless($transp)
Branch: 1 branch
BranchTrueFalseTotal
unless ($transp) 0 0 0
152 0 ▶ { my $type = XML::Compile::Transport->plugin($proto)
Branch: 1 branch
BranchTrueFalseTotal
my $type = "XML::Compile::Transport"->plugin($proto) or &error(&__x("transporter type {proto} not supported (add 'use {pkg}'?)", "proto", $proto, "pkg", "XML::Compile::Transport::SOAPHTTP")) 0 0 0
153 or error __x"transporter type {proto} not supported (add 'use {pkg}'?)"
154 , proto => $proto, pkg => 'XML::Compile::Transport::SOAPHTTP';
155 0 $transp = $type->new(address => \@endpoints, %args);
156 }
157  
158 0 my $transport = $self->{transp_cache}{$proto}{$id} = $transp;
159  
160 $transport->compileClient
161 ( name => $self->name
162 , kind => $self->kind
163 , action => $self->action
164 , hook => $args{transport_hook}
165 0 , %args
166 );
167 }
168  
169  
170 0 ▶sub compileClient(@) { panic "not implemented" }
Subroutine compileClient: not called CC=1 SCAR=6.9
Pod documented
171 0 ▶sub compileHandler(@) { panic "not implemented" }
Subroutine compileHandler: not called CC=1 SCAR=6.9
Pod documented
172  
173 #---------------
174  
175 sub explain($$$@)
176 0 ▶{ my ($self, $wsdl, $format, $dir, %args) = @_;
Subroutine explain: not called CC=1 SCAR=6.9
Pod documented
177 0 panic "not implemented for ".ref $self;
178 }
179  
180  
181 sub parsedWSDL(%)
182 0 ▶{ my $self = shift;
Subroutine parsedWSDL: not called CC=1 SCAR=6.9
Pod documented
183 0 panic "not implemented for ".ref $self;
184 }
185  
186 7 1;
« lib/XML/Compile/SOAP/Trace.pm ↑ Summary blib/lib/XML/Compile/SOAP/Operation.pm »