| 1 | # Copyrights 2007-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-SOAP-Daemon. Meta-POD | ||||||||||||||||||||||||||||||||||
| 6 | # processed 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::Daemon; | ||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 1 | $VERSION = '3.14'; | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Log::Report 'xml-compile-soap-daemon'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use XML::LibXML (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use XML::Compile::Util qw/type_of_node/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use XML::Compile::SOAP (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | # We use HTTP status definitions for each soap protocol, but HTTP::Status | ||||||||||||||||||||||||||||||||||
| 24 | # may not be installed. | ||||||||||||||||||||||||||||||||||
| 25 | use constant | ||||||||||||||||||||||||||||||||||
| 26 | 1 | { RC_SEE_OTHER => 303 | |||||||||||||||||||||||||||||||||
| 27 | , RC_FORBIDDEN => 403 | ||||||||||||||||||||||||||||||||||
| 28 | , RC_NOT_FOUND => 404 | ||||||||||||||||||||||||||||||||||
| 29 | , RC_UNPROCESSABLE_ENTITY => 422 | ||||||||||||||||||||||||||||||||||
| 30 | , RC_NOT_IMPLEMENTED => 501 | ||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | }; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | 1 | my $parser = XML::LibXML->new; | |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | sub new(@) | ||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $class ne __PACKAGE__ | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 39 | or error __x"you can only use extensions of {pkg}", pkg => __PACKAGE__; | ||||||||||||||||||||||||||||||||||
| 40 | 0 | (bless {}, $class)->init( {@_} ); | |||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | sub init($) | ||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 45 | $self->{accept_slow_select} | ||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | = exists $args->{accept_slow_select} ? $args->{accept_slow_select} : 1; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->addWsaTable(INPUT => $args->{wsa_action_input}); | |||||||||||||||||||||||||||||||||
| 49 | 0 | $self->addWsaTable(OUTPUT => $args->{wsa_action_output}); | |||||||||||||||||||||||||||||||||
| 50 | 0 | $self->addSoapAction($args->{soap_action_input}); | |||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if(my $support = delete $args->{support_soap}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 53 | { # simply only load the protocol versions you want to accept. | ||||||||||||||||||||||||||||||||||
| 54 | 0 | error __x"new(support_soap} removed in 2.00"; | |||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | 0 | my @classes = XML::Compile::SOAP->registered; | |||||||||||||||||||||||||||||||||
| 58 | @classes # explicit load required since 2.00 | ||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | or warning "No protocol modules loaded. Need XML::Compile::SOAP11?"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $self->{output_charset} = delete $args->{output_charset} || 'UTF-8'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args->{'output_charset'} || 'UTF-8'
MC/DC0%0/1
delete $args->{'output_charset'} || 'UTF-8'
delete $args->{'output_charset'}
Truth table0%0/2
A
A= delete $args->{'output_charset'}
| |||||||||||||||||||||||||||||||||||
| 62 | 0 | $self->{handler} = {}; | |||||||||||||||||||||||||||||||||
| 63 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | #----------- | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub outputCharset() {shift->{output_charset}} | ||||||||||||||||||||||||||||||||
|
Subroutine
outputCharset: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | sub addWsaTable($@) | ||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | { my ($self, $dir) = (shift, shift); | ||||||||||||||||||||||||||||||||
|
Subroutine
addWsaTable: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $h = @_==1 ? shift : { @_ }; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 74 | my $t = $dir eq 'INPUT' ? ($self->{wsa_input} ||= {}) | ||||||||||||||||||||||||||||||||||
| 75 | : $dir eq 'OUTPUT' ? ($self->{wsa_output} ||= {}) | ||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | : error __x("addWsaTable requires 'INPUT' or 'OUTPUT', not {got}" | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/4
$self->{"wsa_input"} ||= {}
$self->{"wsa_output"} ||= {}
MC/DC0%0/1
$self->{"wsa_input"} ||= {}
$self->{"wsa_input"}
MC/DC0%0/1
$self->{"wsa_output"} ||= {}
$self->{"wsa_output"}
Truth table0%0/2
A
A= $self->{"wsa_input"}
Truth table0%0/2
A
A= $self->{"wsa_output"}
| |||||||||||||||||||||||||||||||||||
| 77 | , got => $dir); | ||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | while(my($op, $action) = each %$h) { $t->{$op} ||= $action } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$t->{$op} ||= $action
MC/DC0%0/2
$t->{$op} ||= $action
$t->{$op}
$action
Truth table0%0/3
A ||= B
A= $t->{$op}B= $action
| |||||||||||||||||||||||||||||||||||
| 80 | 0 | $t; | |||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||
| 84 | sub addSoapAction(@) | ||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
addSoapAction: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | my $h = @_==1 ? shift : { @_ }; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my $t = $self->{sa_input} ||= {}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"sa_input"} ||= {}
MC/DC0%0/1
$self->{"sa_input"} ||= {}
$self->{"sa_input"}
Truth table0%0/2
A
A= $self->{"sa_input"}
| |||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | my $r = $self->{sa_input_rev} ||= {}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"sa_input_rev"} ||= {}
MC/DC0%0/1
$self->{"sa_input_rev"} ||= {}
$self->{"sa_input_rev"}
Truth table0%0/2
A
A= $self->{"sa_input_rev"}
| |||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | while(my($op, $action) = each %$h) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | { $t->{$op} ||= $action; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$t->{$op} ||= $action
MC/DC0%0/2
$t->{$op} ||= $action
$t->{$op}
$action
Truth table0%0/3
A ||= B
A= $t->{$op}B= $action
| |||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | $r->{$action} ||= $op; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$r->{$action} ||= $op
MC/DC0%0/2
$r->{$action} ||= $op
$r->{$action}
$op
Truth table0%0/3
A ||= B
A= $r->{$action}B= $op
| |||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||
| 93 | 0 | $t; | |||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | #------------------ | ||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | sub run(@) | ||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 100 | notice __x"WSA module loaded, but not used" | ||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if XML::Compile::SOAP::WSA->can('new') && !keys %{$self->{wsa_input}}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
"XML::Compile::SOAP::WSA"->can("new") and not keys %{$$self{"wsa_input"};}
MC/DC0%0/2
"XML::Compile::SOAP::WSA"->can("new") and not keys %{$$self{"wsa_input"};}
"XML::Compile::SOAP::WSA"->can("new")
not keys %{$$self{"wsa_input"};}
Truth table0%0/3
A and not(B)
A= "XML::Compile::SOAP::WSA"->can("new")B= not keys %{$$self{"wsa_input"};}
| |||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||
| 103 | 0 | $self->{wsa_input_rev} = +{ reverse %{$self->{wsa_input}} }; | |||||||||||||||||||||||||||||||||
| 104 | 0 | $self->_run(\%args); | |||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||
| 108 | # defined by Net::Server | ||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub process_request(@) { panic "must be extended" } | ||||||||||||||||||||||||||||||||
|
Subroutine
process_request: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | sub process($) | ||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | { my ($self, $input, $req, $soapaction) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
process: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||
| 114 | 0 | my $xmlin; | |||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if(! defined $input) | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 116 | 0 | { return $self->faultNotSoapMessage('No input'); | |||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||
| 118 | elsif(ref $input eq 'SCALAR') | ||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | { $xmlin = try { $parser->parse_string($$input) }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | return $self->faultInvalidXML($@->wasFatal) if $@; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||
| 122 | else | ||||||||||||||||||||||||||||||||||
| 123 | 0 | { $xmlin = $input; | |||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $xmlin = $xmlin->documentElement | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 127 | if $xmlin->isa('XML::LibXML::Document'); | ||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||
| 129 | 0 | my $local = $xmlin->localName; | |||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $local eq 'Envelope' | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 131 | or return $self->faultNotSoapMessage(type_of_node $xmlin); | ||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my $envns = $xmlin->namespaceURI || ''; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$xmlin->namespaceURI || ''
MC/DC0%0/1
$xmlin->namespaceURI || ''
$xmlin->namespaceURI
Truth table0%0/2
A
A= $xmlin->namespaceURI
| |||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | my $proto = XML::Compile::SOAP->fromEnvelope($envns) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 135 | or return $self->faultUnsupportedSoapVersion($envns); | ||||||||||||||||||||||||||||||||||
| 136 | # proto is a XML::Compile::SOAP*::Operation | ||||||||||||||||||||||||||||||||||
| 137 | 0 | my $server = $proto->serverClass; | |||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||
| 139 | 0 | my $info = XML::Compile::SOAP->messageStructure($xmlin); | |||||||||||||||||||||||||||||||||
| 140 | 0 | my $version = $info->{soap_version} = $proto->version; | |||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | my $handlers = $self->{handler}{$version} || {}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'handler'}{$version} || {}
MC/DC0%0/1
$self->{'handler'}{$version} || {}
$self->{'handler'}{$version}
Truth table0%0/2
A
A= $self->{'handler'}{$version}
| |||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | # Try to resolve operation via WSA | ||||||||||||||||||||||||||||||||||
| 144 | 0 | my $wsa_in = $self->{wsa_input_rev}; | |||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if(my $wsa_action = $info->{wsa_action}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | { if(my $name = $wsa_in->{$wsa_action}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 147 | 0 | { my $handler = $handlers->{$name}; | |||||||||||||||||||||||||||||||||
| 148 | 0 | local $info->{selected_by} = 'wsa-action'; | |||||||||||||||||||||||||||||||||
| 149 | 0 | my ($rc, $msg, $xmlout) = $handler->($name, $xmlin, $info, $req); | |||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if($xmlout) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 151 | 0 | { trace "data ready for $version $name, via wsa $wsa_action"; | |||||||||||||||||||||||||||||||||
| 152 | 0 | return ($rc, $msg, $xmlout); | |||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | # Try to resolve operation via soapAction | ||||||||||||||||||||||||||||||||||
| 158 | 0 | my $sa = $self->{sa_input_rev}; | |||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if(defined $soapaction) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | { if(my $name = $sa->{$soapaction}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 161 | 0 | { my $handler = $handlers->{$name}; | |||||||||||||||||||||||||||||||||
| 162 | 0 | local $info->{selected_by} = 'soap-action'; | |||||||||||||||||||||||||||||||||
| 163 | 0 | my ($rc, $msg, $xmlout) = $handler->($name, $xmlin, $info, $req); | |||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if($xmlout) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 165 | 0 | { trace "data ready for $version $name, via sa '$soapaction'"; | |||||||||||||||||||||||||||||||||
| 166 | 0 | return ($rc, $msg, $xmlout); | |||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||
| 171 | # Last resort, try each of the operations for the first which | ||||||||||||||||||||||||||||||||||
| 172 | # can be parsed correctly. | ||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if($self->{accept_slow_select}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 174 | 0 | { keys %$handlers; # reset each() | |||||||||||||||||||||||||||||||||
| 175 | 0 | $info->{selected_by} = 'attempt all'; | |||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | while(my ($name, $handler) = each %$handlers) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 177 | 0 | { my ($rc, $msg, $xmlout) = $handler->($name, $xmlin, $info, $req); | |||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | defined $xmlout or next; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | 0 | trace "data ready for $version $name"; | |||||||||||||||||||||||||||||||||
| 181 | 0 | return ($rc, $msg, $xmlout); | |||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | my $bodyel = $info->{body}[0] || '(none)'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$info->{'body'}[0] || '(none)'
MC/DC0%0/1
$info->{'body'}[0] || '(none)'
$info->{'body'}[0]
Truth table0%0/2
A
A= $info->{'body'}[0]
| |||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | my @other = sort grep {$_ ne $version && keys %{$self->{$_}}} | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 187 | $self->soapVersions; | ||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | return (RC_SEE_OTHER, 'SOAP protocol not in use' | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 190 | , $server->faultTryOtherProtocol($bodyel, \@other)) | ||||||||||||||||||||||||||||||||||
| 191 | if @other; | ||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||
| 193 | # we do not have the names of the request body elements here :( | ||||||||||||||||||||||||||||||||||
| 194 | 0 | my @ports = sort keys %$handlers; | |||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||
| 196 | 0 | ( RC_NOT_FOUND, 'message not recognized' | |||||||||||||||||||||||||||||||||
| 197 | , $server->faultMessageNotRecognized($bodyel, $soapaction, \@ports) | ||||||||||||||||||||||||||||||||||
| 198 | ); | ||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||
| 201 | #------------------ | ||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||
| 203 | sub operationsFromWSDL($@) | ||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | { my ($self, $wsdl, %args) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
operationsFromWSDL: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my %callbacks = $args{callbacks} ? %{$args{callbacks}} : (); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 206 | 0 | my %names; | |||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||
| 208 | 0 | my $default_cb = $args{default_callback}; | |||||||||||||||||||||||||||||||||
| 209 | 0 | my $wsa_input = $self->{wsa_input}; | |||||||||||||||||||||||||||||||||
| 210 | 0 | my $wsa_output = $self->{wsa_output}; | |||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||
| 212 | 0 | my $ops = $args{operations}; | |||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | my @ops = $ops ? @$ops : $wsdl->operations(%args); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | @ops or return; # none selected | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||
| 216 | 0 | foreach my $op (@ops) | |||||||||||||||||||||||||||||||||
| 217 | 0 | { my $name = $op->name; | |||||||||||||||||||||||||||||||||
| 218 | warning __x"multiple operations with name `{name}'", name => $name | ||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if $names{$name}++; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||
| 221 | 0 | my $code; | |||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if(my $callback = $callbacks{$name}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | { UNIVERSAL::isa($callback, 'CODE') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 224 | or error __x"callback {name} must provide a CODE ref" | ||||||||||||||||||||||||||||||||||
| 225 | , name => $name; | ||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||
| 227 | 0 | trace __x"add handler for operation `{name}'", name => $name; | |||||||||||||||||||||||||||||||||
| 228 | 0 | $code = $op->compileHandler(callback => $callback); | |||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||
| 230 | else | ||||||||||||||||||||||||||||||||||
| 231 | 0 | { trace __x"add stub handler for operation `{name}'", name => $name; | |||||||||||||||||||||||||||||||||
| 232 | my $handler = $default_cb | ||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | || sub { $_[0]->faultNotImplemented($name) }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$default_cb || sub {
$_[0]->faultNotImplemented($name);
}
MC/DC0%0/2
$default_cb || sub {
$_[0]->faultNotImplemented($name);
}
$default_cb
sub {
$_[0]->faultNotImplemented($name);
}
Truth table0%0/3
A || B
A= $default_cbB= sub {
$_[0]->faultNotImplemented($name);
}
| |||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||
| 235 | 0 | $code = $op->compileHandler(callback => $handler); | |||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||
| 238 | 0 | $self->addHandler($name, $op, $code); | |||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if($op->can('wsaAction')) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 241 | 0 | { my $in = $op->wsaAction('INPUT'); | |||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $wsa_input->{$name} = $in if defined $in; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 243 | 0 | my $out = $op->wsaAction('OUTPUT'); | |||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $wsa_output->{$name} = $out if defined $out; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||
| 246 | 0 | $self->addSoapAction($name, $op->soapAction); | |||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||
| 249 | 0 | info __x"added {nr} operations from WSDL", nr => (scalar @ops); | |||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if(keys %names != keys %callbacks) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 252 | { $names{$_} | ||||||||||||||||||||||||||||||||||
| 253 | or warning __x"no operation for callback handler `{name}'",name=>$_ | ||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | for sort keys %callbacks; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||
| 257 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||
| 261 | sub addHandler($$$) | ||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | { my ($self, $name, $soap, $code) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
addHandler: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | my $version = ref $soap ? $soap->version : $soap; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 265 | 0 | $self->{handler}{$version}{$name} = $code; | |||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||
| 269 | sub setWsdlResponse($;$) | ||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | { my ($self, $filename, $type) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
setWsdlResponse: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | panic "not implemented by backend {pkg}", pkg => (ref $self || $self); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||
| 274 | #------------------ | ||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||
| 276 | sub handlers($) | ||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | { my ($self, $soap) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
handlers: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my $version = ref $soap ? $soap->version : $soap; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | my $table = $self->{handler}{$version} || {}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'handler'}{$version} || {}
MC/DC0%0/1
$self->{'handler'}{$version} || {}
$self->{'handler'}{$version}
Truth table0%0/2
A
A= $self->{'handler'}{$version}
| |||||||||||||||||||||||||||||||||||
| 280 | 0 | keys %$table; | |||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub soapVersions() { sort keys %{shift->{handler}} } | ||||||||||||||||||||||||||||||||
|
Subroutine
soapVersions: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||
| 287 | sub printIndex(;$) | ||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
printIndex: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | my $fh = shift || \*STDOUT; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || \*STDOUT
MC/DC0%0/1
shift() || \*STDOUT
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||
| 291 | 0 | foreach my $version ($self->soapVersions) | |||||||||||||||||||||||||||||||||
| 292 | 0 | { my @handlers = $self->handlers($version); | |||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | @handlers or next; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||
| 295 | 0 | local $" = "\n "; | |||||||||||||||||||||||||||||||||
| 296 | 0 | $fh->print("$version:\n @handlers\n"); | |||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||
| 301 | sub faultInvalidXML($) | ||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | { my ($self, $error) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
faultInvalidXML: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 303 | 0 | ( RC_UNPROCESSABLE_ENTITY, 'XML syntax error' | |||||||||||||||||||||||||||||||||
| 304 | , __x("The XML cannot be parsed: {error}", error => $error)); | ||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||
| 308 | sub faultNotSoapMessage($) | ||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | { my ($self, $type) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
faultNotSoapMessage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 310 | 0 | ( RC_FORBIDDEN, 'message not SOAP' | |||||||||||||||||||||||||||||||||
| 311 | , __x( "The message was XML, but not SOAP; not an Envelope but `{type}'" | ||||||||||||||||||||||||||||||||||
| 312 | , type => $type)); | ||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||
| 316 | sub faultUnsupportedSoapVersion($) | ||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | { my ($self, $envns) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
faultUnsupportedSoapVersion: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 318 | 0 | ( RC_NOT_IMPLEMENTED, 'SOAP version not supported' | |||||||||||||||||||||||||||||||||
| 319 | , __x("The soap version `{envns}' is not supported", envns => $envns)); | ||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||
| 322 | #------------------ | ||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||
| 324 | 1 | 1; | |||||||||||||||||||||||||||||||||