| 1 | package XML::Compile::SOAP::Daemon::Dancer2::Handler; | ||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 3 | $VERSION = '0.1'; | |||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use parent 'XML::Compile::SOAP::Daemon'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Log::Report 'xml-compile-soap-daemon'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | use constant | ||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | { RC_OK => 200 | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | , RC_METHOD_NOT_ALLOWED => 405 | ||||||||||||||||||||||||||||||||||||||
| 16 | , RC_NOT_ACCEPTABLE => 406 | ||||||||||||||||||||||||||||||||||||||
| 17 | , RC_SERVER_ERROR => 500 | ||||||||||||||||||||||||||||||||||||||
| 18 | 3 | }; | |||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||
| 20 | #-------------------- | ||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | sub init($) | ||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 25 | 4 | $self->SUPER::init($args); | |||||||||||||||||||||||||||||||||||||
| 26 | 4 | $self->_init($args); | |||||||||||||||||||||||||||||||||||||
| 27 | 4 | $self; | |||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | sub _init($) | ||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 34 | 4 | $self->{preprocess} = $args->{preprocess}; | |||||||||||||||||||||||||||||||||||||
| 35 | 4 | $self->{postprocess} = $args->{postprocess}; | |||||||||||||||||||||||||||||||||||||
| 36 | 4 | $self; | |||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | 3 | my $parser = XML::LibXML->new; | |||||||||||||||||||||||||||||||||||||
| 41 | sub handle($) | ||||||||||||||||||||||||||||||||||||||
| 42 | 4 | ▶ | { my ($self, $dsl) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
handle: called CC=21 SCAR=37.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | notice __x"WSA module loaded, but not used" | ||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if XML::Compile::SOAP::WSA->can('new') && !keys %{$self->{wsa_input}}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/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 table33%1/3
A and not(B)
A= "XML::Compile::SOAP::WSA"->can("new")B= not keys %{$$self{"wsa_input"};}
| |||||||||||||||||||||||||||||||||||||||
| 46 | 4 | $self->{wsa_input_rev} = +{ reverse %{$self->{wsa_input}} }; | |||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||
| 48 | #return $self->sendWsdl($req) | ||||||||||||||||||||||||||||||||||||||
| 49 | #if $req->method eq 'GET' && uc($req->uri->query || '') eq 'WSDL'; | ||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | 4 | my $method = $dsl->app->request->method; | |||||||||||||||||||||||||||||||||||||
| 52 | 4 | ▶ | my $ct = $dsl->app->request->content_type || 'text/plain'; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$dsl->app->request->content_type || 'text/plain'
MC/DC0%0/1
$dsl->app->request->content_type || 'text/plain'
$dsl->app->request->content_type
Truth table50%1/2
A
A= $dsl->app->request->content_type
| |||||||||||||||||||||||||||||||||||||||
| 53 | 4 | $ct =~ s/\;\s.*//; | |||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | 4 | my ($rc, $msg, $err, $content, $mime); | |||||||||||||||||||||||||||||||||||||
| 56 | 4 | ▶ | if($method ne 'POST' && $method ne 'M-POST') | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$method ne "POST" and $method ne "M-POST"
MC/DC0%0/2
$method ne "POST" and $method ne "M-POST"
$method ne "POST"
$method ne "M-POST"
Truth table33%1/3
A and B
A= $method ne "POST"B= $method ne "M-POST"
| |||||||||||||||||||||||||||||||||||||||
| 57 | 0 | { ($rc, $msg) = (RC_METHOD_NOT_ALLOWED, 'only POST or M-POST'); | |||||||||||||||||||||||||||||||||||||
| 58 | 0 | $err = 'attempt to connect via GET'; | |||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | elsif($ct !~ m/\bxml\b/) | ||||||||||||||||||||||||||||||||||||||
| 61 | 0 | { ($rc, $msg) = (RC_NOT_ACCEPTABLE, 'required is XML'); | |||||||||||||||||||||||||||||||||||||
| 62 | 0 | $err = 'content-type seems to be '.$ct.', must be some XML'; | |||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||
| 64 | else | ||||||||||||||||||||||||||||||||||||||
| 65 | 4 | ▶ | { my $charset = $dsl->app->request->headers->content_type_charset || 'ascii'; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$dsl->app->request->headers->content_type_charset || 'ascii'
MC/DC0%0/1
$dsl->app->request->headers->content_type_charset || 'ascii'
$dsl->app->request->headers->content_type_charset
Truth table50%1/2
A
A= $dsl->app->request->headers->content_type_charset
| |||||||||||||||||||||||||||||||||||||||
| 66 | 4 | ▶ | my $xmlin = try { $parser->parse_string( decode( $charset, $dsl->app->request->content ) ); }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||
| 68 | 4 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ($rc, $msg, $err) = $self->faultInvalidXML($@->died); | |||||||||||||||||||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||||||||||||||||||||
| 71 | 4 | my $version = undef; | |||||||||||||||||||||||||||||||||||||
| 72 | 4 | ▶ | $xmlin= $xmlin->documentElement | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 73 | if $xmlin->isa('XML::LibXML::Document'); | ||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||
| 75 | 4 | my $local = $xmlin->localName; | |||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||
| 77 | 4 | ▶ | if( $local eq 'Envelope' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | my $envns = $xmlin->namespaceURI || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$xmlin->namespaceURI || ''
MC/DC0%0/1
$xmlin->namespaceURI || ''
$xmlin->namespaceURI
Truth table50%1/2
A
A= $xmlin->namespaceURI
| |||||||||||||||||||||||||||||||||||||||
| 79 | 4 | my $proto = XML::Compile::SOAP->fromEnvelope($envns); | |||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | if( $proto ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 81 | 4 | $version = $proto->version; | |||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||
| 84 | 4 | ▶ | my $action = $dsl->app->request->header('SOAPAction') || $dsl->app->request->header('Action') || $dsl->app->request->header('action') || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition50%4/8
$dsl->app->request->header('SOAPAction') || $dsl->app->request->header('Action') || $dsl->app->request->header('action') || ''
$dsl->app->request->header("SOAPAction") or $dsl->app->request->header("Action") or $dsl->app->request->header("action")
$dsl->app->request->header("SOAPAction") or $dsl->app->request->header("Action")
MC/DC0%0/3
$dsl->app->request->header('SOAPAction') || $dsl->app->request->header('Action') || $dsl->app->request->header('action') || ''
$dsl->app->request->header("SOAPAction")
$dsl->app->request->header("Action")
$dsl->app->request->header("action")
Truth table50%2/4
A or B or C
A= $dsl->app->request->header("SOAPAction")B= $dsl->app->request->header("Action")C= $dsl->app->request->header("action")
| |||||||||||||||||||||||||||||||||||||||
| 85 | 4 | $action =~ s/["'\s]//g; # sometimes illegal quoting and blanks " | |||||||||||||||||||||||||||||||||||||
| 86 | 4 | ($rc, $msg, my $xmlout) = $self->process($xmlin, $dsl, $action); | |||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | if(UNIVERSAL::isa($xmlout, 'XML::LibXML::Document')) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||
| 90 | 4 | ▶ | $content = $xmlout->toString($rc == RC_OK ? 0 : 1); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 91 | 4 | ▶ | if( $version eq "SOAP11" ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 92 | 2 | $mime = 'text/xml; charset="utf-8"'; | |||||||||||||||||||||||||||||||||||||
| 93 | } else { | ||||||||||||||||||||||||||||||||||||||
| 94 | 2 | $mime = "application/soap+xml; charset=utf-8"; | |||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||
| 97 | else | ||||||||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $err = $xmlout; | |||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | 4 | ▶ | if( $err ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $content = $err;# $bytes = "[$rc] $err\n"; | |||||||||||||||||||||||||||||||||||||
| 106 | 0 | $mime = 'text/plain'; | |||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||
| 108 | 4 | $dsl->status( $rc ); | |||||||||||||||||||||||||||||||||||||
| 109 | 4 | $dsl->content_type( $mime ); | |||||||||||||||||||||||||||||||||||||
| 110 | 4 | ▶ | $dsl->header( Warning => "199 $msg" ) if length( $msg ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 111 | #$dsl->content_length(length $bytes); | ||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return $content; | |||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||
| 115 | 3 | 1; | |||||||||||||||||||||||||||||||||||||