lib/XML/Compile/WSDL11.pm

filter: Statementstmt 74.3% 217 / 292 Branchbran 44.6% 84 / 188 Conditioncond 27.0% 13 / 48 MC/DCmcdc 9.6% 3 / 31 Subroutinesub 78.0% 32 / 41 Podpod 88.2% 15 / 17 totaltotal 59.0% 364 / 617 SCAR 70.9
CC
127
Cov
59%
addWSDL
103.1
operation
73.1
compileCall
42.0
CRAP 1200.9
« blib/lib/XML/Compile/WSDL11.pm ↑ Summary
1 # Copyrights 2014-2017 by [Mark Overmeer].
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 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package XML::Compile::WSDL11;
9 5 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 $VERSION = '3.06';
11  
12 5 ▶use base 'XML::Compile::Cache';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 5 ▶use Log::Report 'xml-compile-soap', syntax => 'SHORT';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 5 ▶use XML::Compile ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use XML::Compile::Util qw/pack_type unpack_type/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use XML::Compile::SOAP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use XML::Compile::SOAP::Util qw/:wsdl11/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use XML::Compile::SOAP::Extension;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 5 ▶use XML::Compile::SOAP::Operation ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use XML::Compile::Transport ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 5 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26 5 ▶use List::Util qw/first/;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 ▶use Scalar::Util qw/blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 5 ▶use File::Basename qw/dirname/;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30  
31 sub init($)
32 5 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=6 SCAR=18.0
Pod undocumented
33 5 ▶ $args->{schemas} and panic "new(schemas) option removed in 0.78";
Branch: 1 branch
BranchTrueFalseTotal
$args->{"schemas"} and &panic("new(schemas) option removed in 0.78") 0 5 5
34 5 my $wsdl = delete $args->{top};
35  
36 5 local $args->{any_element} = 'ATTEMPT';
37 5 local $args->{any_attribute} = 'ATTEMPT'; # not implemented
38 5 local $args->{allow_undeclared} = 1;
39  
40 5 $self->SUPER::init($args);
41  
42 5 $self->{index} = {};
43  
44 5 $self->addPrefixes(wsdl => WSDL11, soap => WSDL11SOAP, http => WSDL11HTTP);
45  
46 # next modules should change into an extension as well...
47 $_->can('_initWSDL11') && $_->_initWSDL11($self)
48 5 ▶ for XML::Compile::SOAP->registered;
Branch: 1 branch
BranchTrueFalseTotal
$_->can("_initWSDL11") and $_->_initWSDL11($self) 5 0 5
49  
50 5 XML::Compile::SOAP::Extension->wsdl11Init($self, $args);
51  
52 5 $self->declare
53 ( READER => 'wsdl:definitions'
54 , key_rewrite => 'PREFIXED(wsdl,soap,http)'
55 , hook => {type => 'wsdl:tOperation', after => 'ELEMENT_ORDER'}
56 );
57  
58 5 $self->{XCW_dcopts} = {};
59 5 $self->{XCW_server} = $args->{server_type};
60  
61 5 my @xsds = map File::Spec->catdir(dirname(__FILE__), 'WSDL11', 'xsd', $_)
62 , qw(wsdl.xsd wsdl-mime.xsd wsdl-http.xsd);
63  
64 5 $self->importDefinitions(\@xsds, element_form_default => 'qualified');
65  
66 5 ▶ $self->addWSDL($_) for ref $wsdl eq 'ARRAY' ? @$wsdl : $wsdl;
Branch: 1 branch
BranchTrueFalseTotal
ref $wsdl eq 'ARRAY' ? : 0 5 5
67 5 $self;
68 }
69  
70 0 ▶sub schemas(@) { panic "schemas() removed in v2.00, not needed anymore" }
Subroutine schemas: not called CC=1 SCAR=6.9
Pod undocumented
71  
72 #--------------------------
73  
74  
75 sub compileAll(;$$)
76 0 ▶{ my ($self, $need, $usens) = @_;
Subroutine compileAll: not called CC=5 SCAR=34.0
Pod documented
77 0 ▶ $self->SUPER::compileAll($need, $usens)
Branch: 1 branch
BranchTrueFalseTotal
if not $need or $need ne "CALLS" 0 0 0
Condition0%0/3
not $need or $need ne "CALLS"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $need or $need ne "CALLS"
not $need $need ne "CALLS"
Truth table0%0/3
not(A) or B
A= not $needB= $need ne "CALLS"
ABresult
1X1
011
000
78 if !$need || $need ne 'CALLS';
79  
80 0 ▶ $self->compileCalls
Branch: 1 branch
BranchTrueFalseTotal
if not $need or $need eq "CALLS" 0 0 0
Condition0%0/3
not $need or $need eq "CALLS"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $need or $need eq "CALLS"
not $need $need eq "CALLS"
Truth table0%0/3
not(A) or B
A= not $needB= $need eq "CALLS"
ABresult
1X1
011
000
81 if !$need || $need eq 'CALLS';
82 0 $self;
83 }
84  
85  
86 sub compileCalls(@)
87 0 ▶{ my ($self, %args) = @_;
Subroutine compileCalls: not called CC=3 SCAR=24.8
Pod documented
88 0 my $long = $args{long_names};
89  
90 my @ops = $self->operations
91 ( service => delete $args{service}
92 , port => delete $args{port}
93 , binding => delete $args{binding}
94 0 );
95  
96 0 foreach my $op (@ops)
97 0 ▶ { my $alias = $long ? $op->longName : undef;
Branch: 1 branch
BranchTrueFalseTotal
$long ? : 0 0 0
98 0 $self->compileCall($op, alias => $alias, %args);
99 }
100  
101 0 $self;
102 }
103  
104  
105 sub compileCall($@)
106 0 ▶{ my ($self, $oper, %opts) = @_;
Subroutine compileCall: not called CC=6 SCAR=37.4
Pod documented
107 0 my $alias = delete $opts{alias};
108 0 ▶ my $op = blessed $oper ? $oper : $self->operation($oper, %opts);
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($oper) ? : 0 0 0
109  
110 0 ▶ my $name = $alias || $op->name;
Condition0%0/3
$alias || $op->name
l!l&&r!l&&!r
000
MC/DC0%0/2
$alias || $op->name
$alias $op->name
Truth table0%0/3
A || B
A= $aliasB= $op->name
ABresult
1X1
011
000
111 error __x"a compiled call for {name} already exists", name => $name
112 0 ▶ if $self->{XCW_ccode}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"XCW_ccode"}{$name} 0 0 0
113  
114 0 ▶ my $dopts = $self->{XCW_dcopts} || {};
Condition0%0/2
$self->{'XCW_dcopts'} || {}
l!l
00
MC/DC0%0/1
$self->{'XCW_dcopts'} || {}
$self->{'XCW_dcopts'}
Truth table0%0/2
A
A= $self->{'XCW_dcopts'}
Aresult
11
00
115 0 my @opts = %opts;
116 0 ▶ push @opts, ref $dopts eq 'ARRAY' ? @$dopts : %$dopts;
Branch: 1 branch
BranchTrueFalseTotal
ref $dopts eq 'ARRAY' ? : 0 0 0
117 0 trace "compiling call `$name'";
118 0 $self->{XCW_ccode}{$name} = $op->compileClient(@opts);
119 }
120  
121  
122 sub call($@)
123 0 ▶{ my ($self, $name) = (shift, shift);
Subroutine call: not called CC=3 SCAR=24.8
Pod documented
124  
125 my $codes = $self->{XCW_ccode}
126 0 ▶ or error __x"you can only use call() after compileCalls()";
Branch: 1 branch
BranchTrueFalseTotal
my $codes = $self->{"XCW_ccode"} or &error(&__x("you can only use call() after compileCalls()")) 0 0 0
127  
128 0 ▶ my $call = $codes->{$name}
Branch: 1 branch
BranchTrueFalseTotal
my $call = $codes->{$name} or &error(&__x("operation `{name}' is not known", "name", $name)) 0 0 0
129 or error __x"operation `{name}' is not known", name => $name;
130
131 0 $call->(@_);
132 }
133  
134 #--------------------------
135  
136  
137 sub addWSDL($%)
138 6 ▶{ my ($self, $data, %args) = @_;
Subroutine addWSDL: called CC=25 SCAR=46.4
Pod documented
139 6 ▶ defined $data or return ();
Branch: 1 branch
BranchTrueFalseTotal
defined $data or return () 0 6 6
140  
141 6 ▶ if(ref $data eq 'ARRAY')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq "ARRAY") 0 6 6
142 0 { $self->addWSDL($_) for @$data;
143 0 return $self;
144 }
145  
146 6 my ($node, %details) = $self->dataToXML($data);
147 6 ▶ defined $node or return $self;
Branch: 1 branch
BranchTrueFalseTotal
defined $node or return $self 0 6 6
148  
149 6 ▶ $node->localName eq 'definitions' && $node->namespaceURI eq WSDL11
Branch: 1 branch
BranchTrueFalseTotal
$node->localName eq "definitions" and $node->namespaceURI eq "http://schemas.xmlsoap.org/wsdl/" or &error(&__x("root element for WSDL is not 'wsdl:definitions'")) 0 6 6
Condition33%1/3
$node->localName eq "definitions" and $node->namespaceURI eq "http://schemas.xmlsoap.org/wsdl/"
!ll&&!rl&&r
006
MC/DC0%0/2
$node->localName eq "definitions" and $node->namespaceURI eq "http://schemas.xmlsoap.org/wsdl/"
$node->localName eq "definitions" $node->namespaceURI eq "http://schemas.xmlsoap.org/wsdl/"
Truth table33%1/3
A and B
A= $node->localName eq "definitions"B= $node->namespaceURI eq "http://schemas.xmlsoap.org/wsdl/"
ABresult
0X0
100
111
150 or error __x"root element for WSDL is not 'wsdl:definitions'";
151  
152 6 $self->importDefinitions($node, details => \%details);
153 6 $self->learnPrefixes($node);
154  
155 6 my $spec = $self->reader('wsdl:definitions')->($node);
156 my $tns = $spec->{targetNamespace}
157 6 ▶ or error __x"WSDL sets no targetNamespace";
Branch: 1 branch
BranchTrueFalseTotal
my $tns = $spec->{"targetNamespace"} or &error(&__x("WSDL sets no targetNamespace")) 0 6 6
158  
159 # WSDL 1.1 par 2.1.1 says: WSDL def types each in own name-space
160 6 my $index = $self->{index};
161  
162 # silly WSDL structure
163 6 ▶ my $toplevels = $spec->{gr_wsdl_anyTopLevelOptionalElement} || [];
Condition50%1/2
$spec->{'gr_wsdl_anyTopLevelOptionalElement'} || []
l!l
60
MC/DC0%0/1
$spec->{'gr_wsdl_anyTopLevelOptionalElement'} || []
$spec->{'gr_wsdl_anyTopLevelOptionalElement'}
Truth table50%1/2
A
A= $spec->{'gr_wsdl_anyTopLevelOptionalElement'}
Aresult
11
00
164  
165 6 foreach my $toplevel (@$toplevels)
166 33 { my ($which, $def) = %$toplevel; # always only one
167 33 ▶ $which =~ s/^wsdl_(service|message|binding|portType)$/$1/
Branch: 1 branch
BranchTrueFalseTotal
$which =~ s/^wsdl_(service|message|binding|portType)$/$1/ or next 6 27 33
168 or next;
169  
170 27 $index->{$which}{pack_type $tns, $def->{name}} = $def;
171  
172 27 ▶ if($which eq 'service')
Branch: 1 branch
BranchTrueFalseTotal
if ($which eq "service") 5 22 27
173 5 ▶ { foreach my $port ( @{$def->{wsdl_port} || []} )
Branch: 1 branch
BranchTrueFalseTotal
$def->{"wsdl_port"} or [] 0 5 5
174 12 ▶ { my $addr_label = first { /address$/ } keys %$port
Subroutine __ANON__: called CC=1 SCAR=0.0
175 or error __x"no address in port {port}"
176 5 ▶ , port => $port->{name};
Branch: 1 branch
BranchTrueFalseTotal
my $addr_label = &first(sub { /address$/; } , keys %$port) or &error(&__x("no address in port {port}", "port", $port->{"name"})) 0 5 5
177 5 my $first_addr = $port->{$addr_label};
178 5 ▶ $first_addr = $first_addr->[0] if ref $first_addr eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $first_addr eq "ARRAY" 0 5 5
179  
180 # Is XML::Compile::SOAP<version> loaded?
181 5 ▶ ref $first_addr eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
ref $first_addr eq "HASH" or &error(&__x("wsdl namespace {ns} not loaded", "ns", $first_addr->namespaceURI)) 0 5 5
182 or error __x"wsdl namespace {ns} not loaded"
183 , ns => $first_addr->namespaceURI;
184  
185 5 $index->{port}{pack_type $tns, $port->{name}} = $port;
186 }
187 }
188 }
189  
190 # no service block when only one port
191 6 ▶ unless($index->{service})
Branch: 1 branch
BranchTrueFalseTotal
unless ($index->{"service"}) 0 6 6
192 { # only from this WSDL, cannot use collective $index
193 0 ▶ my @portTypes = map $_->{wsdl_portType}||(), @$toplevels;
Condition0%0/3
$_->{'wsdl_portType'} || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->{'wsdl_portType'} || ()
$_->{'wsdl_portType'} ()
Truth table0%0/3
A || B
A= $_->{'wsdl_portType'}B= ()
ABresult
1X1
011
000
194 0 ▶ @portTypes==1
Branch: 1 branch
BranchTrueFalseTotal
@portTypes == 1 or &error(&__x("no service definition so needs 1 portType, found {nr}", "nr", scalar @portTypes)) 0 0 0
195 or error __x"no service definition so needs 1 portType, found {nr}"
196 , nr => scalar @portTypes;
197  
198 0 ▶ my @bindings = map $_->{wsdl_binding}||(), @$toplevels;
Condition0%0/3
$_->{'wsdl_binding'} || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->{'wsdl_binding'} || ()
$_->{'wsdl_binding'} ()
Truth table0%0/3
A || B
A= $_->{'wsdl_binding'}B= ()
ABresult
1X1
011
000
199 0 ▶ @bindings==1
Branch: 1 branch
BranchTrueFalseTotal
@bindings == 1 or &error(&__x("no service definition so needs 1 binding, found {nr}", "nr", scalar @bindings)) 0 0 0
200 or error __x"no service definition so needs 1 binding, found {nr}"
201 , nr => scalar @bindings;
202  
203 0 my $binding = pack_type $tns, $bindings[0]->{name};
204 0 my $portname = $portTypes[0]->{name};
205 0 my $servname = $portname;
206 0 ▶ $servname =~ s/Service$|(?:Service)?Port(?:Type)?$/Service/i
Branch: 1 branch
BranchTrueFalseTotal
$servname =~ s/Service$|(?:Service)?Port(?:Type)?$/Service/i or $servname .= 'Service' 0 0 0
207 or $servname .= 'Service';
208  
209 my $addr
210 = $bindings[0]->{soap_binding} ? 'soap_address'
211 0 ▶ : $bindings[0]->{soap12_binding} ? 'soap12_address'
Branch: 2 branches
BranchTrueFalseTotal
$bindings[0]{'soap_binding'} ? : 0 0 0
$bindings[0]{'soap12_binding'} ? : 0 0 0
212 : error __x"unrecognized binding type for wsdl without service block";
213  
214 0 my %port = (name => $portname, binding => $binding
215 , $addr => {location => 'http://localhost'} );
216  
217 0 $index->{service}{pack_type $tns, $servname}
218 = { name => $servname, wsdl_port => [ \%port ] };
219 0 $index->{port}{pack_type $tns, $portname} = \%port;
220 }
221 #warn "INDEX: ",Dumper $index;
222 6 $self;
223 }
224  
225  
226 sub namesFor($)
227 0 ▶{ my ($self, $class) = @_;
Subroutine namesFor: not called CC=2 SCAR=17.9
Pod documented
228 0 ▶ keys %{shift->index($class) || {}};
Branch: 1 branch
BranchTrueFalseTotal
(shift())->index($class) or {} 0 0 0
229 }
230  
231  
232 # new options, then also add them to the list in compileClient()
233  
234 sub operation(@)
235 9 ▶{ my $self = shift;
Subroutine operation: called CC=34 SCAR=42.9
Pod documented
236 9 ▶ my $name = @_ % 2 ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 7 2 9
237 9 my %args = (name => $name, @_);
238  
239 #
240 ## Service structure
241 #
242  
243 9 my $service = $self->findDef(service => delete $args{service});
244  
245 9 my $port;
246 9 ▶ my @ports = @{$service->{wsdl_port} || []};
Branch: 1 branch
BranchTrueFalseTotal
$service->{"wsdl_port"} or [] 0 9 9
247 9 ▶ if(my $not = first {blessed $_} @ports)
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if (my $not = &first(sub { builtin::blessed($_); } , @ports)) 0 9 9
248 0 { error __x"not all name-spaces loaded, {ns} not parsed in port"
249 , ns => $not->namespaceURI;
250 }
251  
252 9 my @portnames = map $_->{name}, @ports;
253 9 ▶ if(my $portname = delete $args{port})
Branch: 2 branches
BranchTrueFalseTotal
if (my $portname = delete $args{'port'}) { } 2 7 9
elsif (@ports == 1) { } 7 0 7
254 2 ▶ { $port = first {$_->{name} eq $portname} @ports;
Subroutine __ANON__: called CC=1 SCAR=0.0
255 2 ▶ error __x"cannot find port `{portname}', pick from {ports}"
Branch: 1 branch
BranchTrueFalseTotal
unless $port 0 2 2
256 , portname => $portname, ports => join("\n ", '', @portnames)
257 unless $port;
258 }
259 elsif(@ports==1)
260 7 { $port = shift @ports;
261 }
262 else
263 0 { error __x"specify port explicitly, pick from {portnames}"
264 , portnames => join("\n ", '', @portnames);
265 }
266  
267 # get plugin for operation
268 24 ▶ my $address = first { /address$/ && $port->{$_}{location}} keys %$port
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
/address$/ and $port->{$_}{"location"} 9 15 24
269 or error __x"no address provided in service {service} port {port}"
270 9 ▶ , service => $service->{name}, port => $port->{name};
Branch: 1 branch
BranchTrueFalseTotal
my $address = &first(sub { /address$/ and $port->{$_}{"location"}; } , keys %$port) or &error(&__x("no address provided in service {service} port {port}", "service", $service->{"name"}, "port", $port->{"name"})) 0 9 9
271  
272 9 ▶ if($address =~ m/^{/) # }
Branch: 1 branch
BranchTrueFalseTotal
if ($address =~ /^{/) 0 9 9
273 0 { my ($ns) = unpack_type $address;
274  
275 0 ▶ warning __"Since v2.00 you have to require XML::Compile::SOAP11 explicitly"
Branch: 1 branch
BranchTrueFalseTotal
if $ns eq "http://schemas.xmlsoap.org/wsdl/soap/" 0 0 0
276 if $ns eq WSDL11SOAP;
277  
278 0 error __x"ports of type {ns} not supported (not loaded?)", ns => $ns;
279 }
280  
281 #use Data::Dumper;
282 #warn Dumper $port, $self->prefixes;
283 9 my ($prefix) = $address =~ m/(\w+)_address$/;
284 9 ▶ $prefix
Branch: 1 branch
BranchTrueFalseTotal
$prefix or &error(&__x("port address not prefixed; probably need to add a plugin XML::Compile::SOAP12")) 0 9 9
285 or error __x"port address not prefixed; probably need to add a plugin XML::Compile::SOAP12";
286  
287 9 my $opns = $self->findName("$prefix:");
288 9 my $protocol = XML::Compile::SOAP->plugin($opns);
289 9 ▶ unless($protocol)
Branch: 1 branch
BranchTrueFalseTotal
unless ($protocol) 0 9 9
290 0 ▶ { my $pkg = $opns eq WSDL11SOAP ? 'SOAP11'
Branch: 2 branches
BranchTrueFalseTotal
$opns eq 'http://schemas.xmlsoap.org/wsdl/soap/' ? : 0 0 0
$opns eq 'http://schemas.xmlsoap.org/wsdl/soap12/' ? : 0 0 0
291 : $opns eq WSDL11SOAP12 ? 'SOAP12'
292 : undef;
293  
294 0 ▶ if($pkg)
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg) { } 0 0 0
295 0 { error __x"add 'use XML::Compile::{pkg}' to your script", pkg=>$pkg;
296 }
297 else
298 0 { notice __x"ignoring unsupported namespace {ns}", ns => $opns;
299 0 return;
300 }
301 }
302  
303 9 my $opclass = $protocol.'::Operation';
304 9 ▶ $opclass->can('_fromWSDL11')
Branch: 1 branch
BranchTrueFalseTotal
$opclass->can("_fromWSDL11") or &error(&__x("WSDL11 not supported by {class}", "class", $opclass)) 0 9 9
305 or error __x"WSDL11 not supported by {class}", class => $opclass;
306  
307 #
308 ## Binding
309 #
310  
311 my $bindtype = $port->{binding}
312 or error __x"no binding defined in port '{name}'"
313 9 ▶ , name => $port->{name};
Branch: 1 branch
BranchTrueFalseTotal
my $bindtype = $port->{"binding"} or &error(&__x("no binding defined in port '{name}'", "name", $port->{"name"})) 0 9 9
314  
315 9 my $binding = $self->findDef(binding => $bindtype);
316  
317 my $type = $binding->{type} # get portTypeType
318 9 ▶ or error __x"no type defined with binding `{name}'"
Branch: 1 branch
BranchTrueFalseTotal
my $type = $binding->{"type"} or &error(&__x("no type defined with binding `{name}'", "name", $bindtype)) 0 9 9
319 , name => $bindtype;
320  
321 9 my $portType = $self->findDef(portType => $type);
322 my $types = $portType->{wsdl_operation}
323 9 ▶ or error __x"no operations defined for portType `{name}'"
Branch: 1 branch
BranchTrueFalseTotal
my $types = $portType->{"wsdl_operation"} or &error(&__x("no operations defined for portType `{name}'", "name", $type)) 0 9 9
324 , name => $type;
325  
326 9 my @port_ops = map $_->{name}, @$types;
327  
328 9 ▶ $name ||= delete $args{operation};
Condition66%2/3
$name ||= delete $args{"operation"}
l!l&&r!l&&!r
720
MC/DC0%0/2
$name ||= delete $args{"operation"}
$name delete $args{"operation"}
Truth table66%2/3
A ||= B
A= $nameB= delete $args{"operation"}
ABresult
1X1
011
000
329 9 my $port_op;
330 9 ▶ if(defined $name)
Branch: 2 branches
BranchTrueFalseTotal
if (defined $name) { } 9 0 9
elsif (@port_ops == 1) { } 0 0 0
331 9 ▶ { $port_op = first {$_->{name} eq $name} @$types;
Subroutine __ANON__: called CC=1 SCAR=0.0
332 9 ▶ error __x"no operation `{op}' for portType {pt}, pick from{ops}"
Branch: 1 branch
BranchTrueFalseTotal
unless $port_op 1 8 9
333 , op => $name, pt => $type, ops => join("\n ", '', @port_ops)
334 unless $port_op;
335 }
336 elsif(@port_ops==1)
337 0 { $port_op = shift @$types;
338 0 $name = $port_op->{name};
339 }
340 else
341 0 { error __x"multiple operations in portType `{pt}', pick from {ops}"
342 , pt => $type, ops => join("\n ", '', @port_ops)
343 }
344  
345 8 ▶ my @bindops = @{$binding->{wsdl_operation} || []};
Branch: 1 branch
BranchTrueFalseTotal
$binding->{"wsdl_operation"} or [] 0 8 8
346 8 ▶ my $bind_op = first {$_->{name} eq $name} @bindops;
Subroutine __ANON__: called CC=1 SCAR=0.0
347 8 ▶ $bind_op
Branch: 1 branch
BranchTrueFalseTotal
$bind_op or &error(&__x("cannot find bind operation for {name}", "name", $name)) 0 8 8
348 or error __x"cannot find bind operation for {name}", name => $name;
349  
350 # This should be detected while parsing the WSDL because the order of
351 # input and output is significant (and lost), but WSDL 1.1 simplifies
352 # our life by saying that only 2 out-of 4 predefined types can actually
353 # be used at present.
354  
355 8 my @order = map +(unpack_type $_)[1], @{$port_op->{_ELEMENT_ORDER}};
356  
357 8 my ($first_in, $first_out);
358 8 ▶ for(my $i = 0; $i<@order; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @order) 16 8 24
359 16 ▶ { $first_in = $i if !defined $first_in && $order[$i] eq 'input';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $first_in and $order[$i] eq "input" 8 8 16
Condition66%2/3
not defined $first_in and $order[$i] eq "input"
!ll&&!rl&&r
808
MC/DC50%1/2
not defined $first_in and $order[$i] eq "input"
not defined $first_in $order[$i] eq "input"
Truth table66%2/3
not(A) and B
A= not defined $first_inB= $order[$i] eq "input"
ABresult
0X0
100
111
360 16 ▶ $first_out = $i if !defined $first_out && $order[$i] eq 'output';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $first_out and $order[$i] eq "output" 7 9 16
Condition100%3/3
not defined $first_out and $order[$i] eq "output"
!ll&&!rl&&r
187
MC/DC100%2/2
not defined $first_out and $order[$i] eq "output"
not defined $first_out $order[$i] eq "output"
Truth table100%3/3
not(A) and B
A= not defined $first_outB= $order[$i] eq "output"
ABresult
0X0
100
111
361 }
362  
363 8 ▶ my $kind
Branch: 3 branches
BranchTrueFalseTotal
!defined($first_in) ? : 0 8 8
!defined($first_out) ? : 1 7 8
$first_in < $first_out ? : 7 0 7
364 = !defined $first_in ? 'notification-operation'
365 : !defined $first_out ? 'one-way'
366 : $first_in < $first_out ? 'request-response'
367 : 'solicit-response';
368  
369 #
370 ### message components
371 #
372  
373 my $operation = $opclass->_fromWSDL11
374 ( name => $name,
375 , kind => $kind
376  
377 , service => $service
378 , serv_port => $port
379 , binding => $binding
380 , bind_op => $bind_op
381 , portType => $portType
382 , port_op => $port_op
383  
384 , wsdl => $self
385 , action => $args{action}
386  
387 , server_type => $args{server_type} || $self->{XCW_server}
388 8 ▶ );
Condition33%1/3
$args{'server_type'} || $self->{'XCW_server'}
l!l&&r!l&&!r
008
MC/DC0%0/2
$args{'server_type'} || $self->{'XCW_server'}
$args{'server_type'} $self->{'XCW_server'}
Truth table33%1/3
A || B
A= $args{'server_type'}B= $self->{'XCW_server'}
ABresult
1X1
011
000
389
390 8 $operation;
391 }
392  
393  
394 sub compileClient(@)
395 0 ▶{ my $self = shift;
Subroutine compileClient: not called CC=5 SCAR=34.0
Pod documented
396 0 ▶ unshift @_, 'operation' if @_ % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 0 0 0
397 0 ▶ my $op = $self->operation(@_) or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $op = $self->operation(@_) or return () 0 0 0
398  
399 0 ▶ my $dopts = $self->{XCW_dcopts} || {};
Condition0%0/2
$self->{'XCW_dcopts'} || {}
l!l
00
MC/DC0%0/1
$self->{'XCW_dcopts'} || {}
$self->{'XCW_dcopts'}
Truth table0%0/2
A
A= $self->{'XCW_dcopts'}
Aresult
11
00
400 0 ▶ $op->compileClient(@_, (ref $dopts eq 'ARRAY' ? @$dopts : %$dopts));
Branch: 1 branch
BranchTrueFalseTotal
ref $dopts eq 'ARRAY' ? : 0 0 0
401 }
402  
403 #---------------------
404  
405  
406 sub declare($$@)
407 10 ▶{ my ($self, $need, $names, @opts) = @_;
Subroutine declare: called CC=6 SCAR=18.4
Pod documented
408 10 ▶ my $opts = @opts==1 ? shift @opts : \@opts;
Branch: 1 branch
BranchTrueFalseTotal
@opts == 1 ? : 0 10 10
409 10 ▶ $opts = [ %$opts ] if ref $opts eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $opts eq "HASH" 0 10 10
410  
411 10 ▶ $need eq 'OPERATION'
Branch: 1 branch
BranchTrueFalseTotal
$need eq "OPERATION" or $self->SUPER::declare($need, $names, @opts) 10 0 10
412 or $self->SUPER::declare($need, $names, @opts);
413  
414 10 ▶ foreach my $name (ref $names eq 'ARRAY' ? @$names : $names)
Branch: 1 branch
BranchTrueFalseTotal
ref $names eq 'ARRAY' ? : 5 5 10
415 { # checking existence of opname is expensive here
416 # and may be problematic with multiple bindings.
417 35 $self->{XCW_dcopts}{$name} = $opts;
418 }
419  
420 10 $self;
421 }
422  
423 #--------------------------
424  
425  
426 sub index(;$$)
427 53 ▶{ my $index = shift->{index};
Subroutine index: called CC=4 SCAR=14.9
Pod documented
428 53 ▶ @_ or return $index;
Branch: 1 branch
BranchTrueFalseTotal
@_ or return $index 0 53 53
429  
430 53 ▶ my $class = $index->{ (shift) }
Branch: 1 branch
BranchTrueFalseTotal
my $class = $$index{shift()} or return () 0 53 53
431 or return ();
432  
433 53 ▶ @_ ? $class->{ (shift) } : $class;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 53 53
434 }
435  
436  
437 sub findDef($;$)
438 53 ▶{ my ($self, $class, $name) = @_;
Subroutine findDef: called CC=9 SCAR=24.0
Pod documented
439 53 ▶ my $group = $self->index($class)
Branch: 1 branch
BranchTrueFalseTotal
my $group = $self->index($class) or &error(&__x("no definitions for `{class}' found", "class", $class)) 0 53 53
440 or error __x"no definitions for `{class}' found", class => $class;
441  
442 53 ▶ if(defined $name)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 41 12 53
443 41 ▶ { return $group->{$name} if exists $group->{$name}; # QNAME
Branch: 1 branch
BranchTrueFalseTotal
if exists $group->{$name} 38 3 41
444  
445 3 ▶ if($name =~ m/\:/) # PREFIXED
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /\:/) 0 3 3
446 0 { my $qname = $self->findName($name);
447 0 ▶ return $group->{$qname} if exists $group->{$qname};
Branch: 1 branch
BranchTrueFalseTotal
if exists $group->{$qname} 0 0 0
448 }
449  
450 3 ▶ if(my $q = first { (unpack_type $_)[1] eq $name } keys %$group)
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if (my $q = &first(sub { (&unpack_type($_))[1] eq $name; } , keys %$group)) 2 1 3
451 2 { return $group->{$q};
452 }
453  
454 1 error __x"no definition for `{name}' as {class}, pick from:{groups}"
455 , name => $name, class => $class
456 , groups => join("\n ", '', sort keys %$group);
457 }
458  
459 12 ▶ return values %$group
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 9 12
460 if wantarray;
461  
462 9 ▶ return (values %$group)[0]
Branch: 1 branch
BranchTrueFalseTotal
if keys %$group == 1 9 0 9
463 if keys %$group==1;
464 0 my @alts = map $self->prefixed($_), sort keys %$group;
465 0 error __x"explicit selection required: pick one {class} from {alts}"
466 , class => $class, alts => join("\n ", '', @alts);
467 }
468  
469  
470 sub operations(@)
471 2 ▶{ my ($self, %args) = @_;
Subroutine operations: called CC=18 SCAR=36.0
Pod documented
472 2 ▶ $args{produce} and die "produce option removed in 0.81";
Branch: 1 branch
BranchTrueFalseTotal
$args{"produce"} and die "produce option removed in 0.81" 0 2 2
473  
474 2 my @ops;
475 2 my @services = $self->findDef('service');
476 2 foreach my $service (@services)
477 2 { my $sname = $service->{name};
478 2 ▶ next if $args{service} && $args{service} ne $sname;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"service"} and $args{"service"} ne $sname 0 2 2
Condition33%1/3
$args{"service"} and $args{"service"} ne $sname
!ll&&!rl&&r
200
MC/DC0%0/2
$args{"service"} and $args{"service"} ne $sname
$args{"service"} $args{"service"} ne $sname
Truth table33%1/3
A and B
A= $args{"service"}B= $args{"service"} ne $sname
ABresult
0X0
100
111
479  
480 2 ▶ my @ports = @{$service->{wsdl_port} || []};
Branch: 1 branch
BranchTrueFalseTotal
$service->{"wsdl_port"} or [] 0 2 2
481 2 foreach my $port (@ports)
482 {
483 2 ▶ next if $args{port} && $args{port} ne $port->{name};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"port"} and $args{"port"} ne $port->{"name"} 0 2 2
Condition33%1/3
$args{"port"} and $args{"port"} ne $port->{"name"}
!ll&&!rl&&r
200
MC/DC0%0/2
$args{"port"} and $args{"port"} ne $port->{"name"}
$args{"port"} $args{"port"} ne $port->{"name"}
Truth table33%1/3
A and B
A= $args{"port"}B= $args{"port"} ne $port->{"name"}
ABresult
0X0
100
111
484 my $bindtype = $port->{binding}
485 or error __x"no binding defined in port '{name}'"
486 2 ▶ , name => $port->{name};
Branch: 1 branch
BranchTrueFalseTotal
my $bindtype = $port->{"binding"} or &error(&__x("no binding defined in port '{name}'", "name", $port->{"name"})) 0 2 2
487 2 my $binding = $self->findDef(binding => $bindtype);
488  
489 2 ▶ next if $args{binding} && $args{binding} ne $binding->{name};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"binding"} and $args{"binding"} ne $binding->{"name"} 0 2 2
Condition33%1/3
$args{"binding"} and $args{"binding"} ne $binding->{"name"}
!ll&&!rl&&r
200
MC/DC0%0/2
$args{"binding"} and $args{"binding"} ne $binding->{"name"}
$args{"binding"} $args{"binding"} ne $binding->{"name"}
Truth table33%1/3
A and B
A= $args{"binding"}B= $args{"binding"} ne $binding->{"name"}
ABresult
0X0
100
111
490  
491 my $type = $binding->{type}
492 2 ▶ or error __x"no type defined with binding `{name}'"
Branch: 1 branch
BranchTrueFalseTotal
my $type = $binding->{"type"} or &error(&__x("no type defined with binding `{name}'", "name", $bindtype)) 0 2 2
493 , name => $bindtype;
494  
495 2 my %all_ops;
496 2 ▶ foreach my $operation ( @{$binding->{wsdl_operation}||[]} )
Branch: 1 branch
BranchTrueFalseTotal
$binding->{"wsdl_operation"} or [] 0 2 2
497 2 { my $opname = $operation->{name};
498  
499 2 ▶ if(my $has = $all_ops{$opname})
Branch: 1 branch
BranchTrueFalseTotal
if (my $has = $all_ops{$opname}) 0 2 2
500 { error __x"operation {name} found again; choose service {has} or {also}"
501 , name => $opname, has => $has->serviceName
502 , also => $sname
503 0 ▶ if @services > 1 && !$args{service};
Branch: 1 branch
BranchTrueFalseTotal
if @services > 1 and not $args{"service"} 0 0 0
Condition0%0/3
@services > 1 and not $args{"service"}
!ll&&!rl&&r
000
MC/DC0%0/2
@services > 1 and not $args{"service"}
@services > 1 not $args{"service"}
Truth table0%0/3
A and not(B)
A= @services > 1B= not $args{"service"}
ABresult
0X0
100
111
504  
505 error __x"need one set of operations, pick port from {ports}"
506 0 , ports => [ map $_->{name}, @ports ], _join => ', ';
507 }
508
509 my $op = $all_ops{$opname} = $self->operation
510 ( service => $sname
511 , port => $port->{name}
512 , binding => $bindtype
513 , operation => $opname
514 , portType => $type
515 , server_type => $args{server_type}
516 2 );
517  
518 2 push @ops, $op;
519 }
520 }
521 }
522  
523 2 @ops;
524 }
525  
526  
527 sub endPoint(@)
528 2 ▶{ my ($self, %args) = @_;
Subroutine endPoint: called CC=7 SCAR=23.2
Pod documented
529 2 my $service = $self->findDef(service => delete $args{service});
530  
531 2 my $port;
532 2 ▶ my @ports = @{$service->{wsdl_port} || []};
Branch: 1 branch
BranchTrueFalseTotal
$service->{"wsdl_port"} or [] 0 2 2
533 2 my @portnames = map $_->{name}, @ports;
534 2 ▶ if(my $portname = delete $args{port})
Branch: 2 branches
BranchTrueFalseTotal
if (my $portname = delete $args{'port'}) { } 0 2 2
elsif (@ports == 1) { } 2 0 2
535 0 ▶ { $port = first {$_->{name} eq $portname} @ports;
Subroutine __ANON__: not called CC=1 SCAR=6.9
536 0 ▶ error __x"cannot find port `{portname}', pick from {ports}"
Branch: 1 branch
BranchTrueFalseTotal
unless $port 0 0 0
537 , portname => $portname, ports => join("\n ", '', @portnames)
538 unless $port;
539 }
540 elsif(@ports==1)
541 2 { $port = shift @ports;
542 }
543 else
544 0 { error __x"specify port explicitly, pick from {portnames}"
545 , portnames => join("\n ", '', @portnames);
546 }
547  
548 2 foreach my $k (keys %$port)
549 6 ▶ { return $port->{$k}{location} if $k =~ m/address$/;
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /address$/ 2 4 6
550 }
551  
552 0 ();
553 }
554  
555  
556 sub printIndex(@)
557 1 ▶{ my $self = shift;
Subroutine printIndex: called CC=6 SCAR=17.9
Pod documented
558 1 ▶ my $fh = @_ % 2 ? shift : select;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 1 0 1
559 1 my @args = @_;
560  
561 1 my %tree;
562 1 foreach my $op ($self->operations(@args))
563 1 { my $port = $op->version.' port '.$op->portName;
564 1 my $bind = '(binding '.$op->bindingName.')';
565 1 $tree{'service '.$op->serviceName}{"$port $bind"}{$op->name} = $_;
566 }
567  
568 1 foreach my $service (sort keys %tree)
569 1 { $fh->print("$service\n");
570 1 foreach my $port (sort keys %{$tree{$service}})
571 1 { $fh->print(" $port\n");
572 1 foreach my $op (sort keys %{$tree{$service}{$port}})
573 1 { $fh->print(" $op\n");
574 }
575 }
576 }
577 }
578  
579  
580 sub explain($$$@)
581 0 ▶{ my ($self, $opname, $format, $direction, @opts) = @_;
Subroutine explain: not called CC=2 SCAR=17.9
Pod documented
582 0 ▶ my $op = $self->operation($opname, @opts)
Branch: 1 branch
BranchTrueFalseTotal
my $op = $self->operation($opname, @opts) or &error(&__x("explain operation {name} not found", "name", $opname)) 0 0 0
583 or error __x"explain operation {name} not found", name => $opname;
584 0 $op->explain($self, $format, $direction, @opts);
585 }
586  
587 #--------------------------------
588  
589  
590 5 1;
« blib/lib/XML/Compile/WSDL11.pm ↑ Summary