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