| 1 | # $Id: SOAP.pm 83 2008-08-08 01:37:07Z larwan $ | ||||||||||||||||||||||||||||||||||||||||||
| 2 | package POE::Component::Server::SOAP; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # Initialize our version $LastChangedRevision: 83 $ | ||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | $VERSION = '1.14'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # Import the proper POE stuff | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use POE; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use POE::Session; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use POE::Component::Server::SimpleHTTP; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # We need SOAP stuff | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use SOAP::Lite; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use SOAP::Constants; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # Our own modules | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use POE::Component::Server::SOAP::Response; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | # Set some constants | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | if ( ! defined &DEBUG ) { *DEBUG = sub () { 0 } } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # Create a new instance | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=30 SCAR=68.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | # Get the OOP's type | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # Sanity checking | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ( @_ & 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | croak( 'POE::Component::Server::SOAP->new needs even number of options' ); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | # The options hash | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | # Our own options | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my ( $ALIAS, $ADDRESS, $PORT, $HEADERS, $HOSTNAME, $MUSTUNDERSTAND, $SIMPLEHTTP ); | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | # You could say I should do this: $Stuff = delete $opt{'Stuff'} | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # But, that kind of behavior is not defined, so I would not trust it... | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | # Get the session alias | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if ( exists $opt{'ALIAS'} and defined $opt{'ALIAS'} and length( $opt{'ALIAS'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $opt{"ALIAS"} and defined $opt{"ALIAS"} and length $opt{"ALIAS"}
exists $opt{"ALIAS"} and defined $opt{"ALIAS"}
MC/DC0%0/3
exists $opt{"ALIAS"} and defined $opt{"ALIAS"} and length $opt{"ALIAS"}
exists $opt{"ALIAS"}
defined $opt{"ALIAS"}
length $opt{"ALIAS"}
Truth table0%0/4
A and B and C
A= exists $opt{"ALIAS"}B= defined $opt{"ALIAS"}C= length $opt{"ALIAS"}
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $ALIAS = $opt{'ALIAS'}; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | delete $opt{'ALIAS'}; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # Debugging info... | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 54 | warn 'Using default ALIAS = SOAPServer'; | ||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | # Set the default | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $ALIAS = 'SOAPServer'; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | # Remove any lingering ALIAS | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( exists $opt{'ALIAS'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | delete $opt{'ALIAS'}; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | # Get the PORT | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ( exists $opt{'PORT'} and defined $opt{'PORT'} and length( $opt{'PORT'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $opt{"PORT"} and defined $opt{"PORT"} and length $opt{"PORT"}
exists $opt{"PORT"} and defined $opt{"PORT"}
MC/DC0%0/3
exists $opt{"PORT"} and defined $opt{"PORT"} and length $opt{"PORT"}
exists $opt{"PORT"}
defined $opt{"PORT"}
length $opt{"PORT"}
Truth table0%0/4
A and B and C
A= exists $opt{"PORT"}B= defined $opt{"PORT"}C= length $opt{"PORT"}
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $PORT = $opt{'PORT'}; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | delete $opt{'PORT'}; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | # Debugging info... | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 73 | warn 'Using default PORT = 80'; | ||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | # Set the default | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $PORT = 80; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | # Remove any lingering PORT | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( exists $opt{'PORT'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | delete $opt{'PORT'}; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | # Get the ADDRESS | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ( exists $opt{'ADDRESS'} and defined $opt{'ADDRESS'} and length( $opt{'ADDRESS'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $opt{"ADDRESS"} and defined $opt{"ADDRESS"} and length $opt{"ADDRESS"}
exists $opt{"ADDRESS"} and defined $opt{"ADDRESS"}
MC/DC0%0/3
exists $opt{"ADDRESS"} and defined $opt{"ADDRESS"} and length $opt{"ADDRESS"}
exists $opt{"ADDRESS"}
defined $opt{"ADDRESS"}
length $opt{"ADDRESS"}
Truth table0%0/4
A and B and C
A= exists $opt{"ADDRESS"}B= defined $opt{"ADDRESS"}C= length $opt{"ADDRESS"}
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $ADDRESS = $opt{'ADDRESS'}; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | delete $opt{'ADDRESS'}; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | croak( 'ADDRESS is required to create a new POE::Component::Server::SOAP instance!' ); | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | # Get the HEADERS | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ( exists $opt{'HEADERS'} and defined $opt{'HEADERS'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $opt{"HEADERS"} and defined $opt{"HEADERS"}
MC/DC0%0/2
exists $opt{"HEADERS"} and defined $opt{"HEADERS"}
exists $opt{"HEADERS"}
defined $opt{"HEADERS"}
Truth table0%0/3
A and B
A= exists $opt{"HEADERS"}B= defined $opt{"HEADERS"}
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | # Make sure it is ref to hash | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ( ref $opt{'HEADERS'} and ref( $opt{'HEADERS'} ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $opt{"HEADERS"} and ref $opt{"HEADERS"} eq "HASH"
MC/DC0%0/2
ref $opt{"HEADERS"} and ref $opt{"HEADERS"} eq "HASH"
ref $opt{"HEADERS"}
ref $opt{"HEADERS"} eq "HASH"
Truth table0%0/3
A and B
A= ref $opt{"HEADERS"}B= ref $opt{"HEADERS"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $HEADERS = $opt{'HEADERS'}; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | delete $opt{'HEADERS'}; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | croak( 'HEADERS must be a reference to a HASH!' ); | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | # Debugging info... | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 105 | warn 'Using default HEADERS ( SERVER => POE::Component::Server::SOAP/' . $VERSION . ' )'; | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | # Set the default | ||||||||||||||||||||||||||||||||||||||||||
| 109 | $HEADERS = { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | 'Server' => 'POE::Component::Server::SOAP/' . $VERSION, | |||||||||||||||||||||||||||||||||||||||||
| 111 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | # Remove any lingering HEADERS | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( exists $opt{'HEADERS'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | delete $opt{'HEADERS'}; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | # Get the HOSTNAME | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if ( exists $opt{'HOSTNAME'} and defined $opt{'HOSTNAME'} and length( $opt{'HOSTNAME'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $opt{"HOSTNAME"} and defined $opt{"HOSTNAME"} and length $opt{"HOSTNAME"}
exists $opt{"HOSTNAME"} and defined $opt{"HOSTNAME"}
MC/DC0%0/3
exists $opt{"HOSTNAME"} and defined $opt{"HOSTNAME"} and length $opt{"HOSTNAME"}
exists $opt{"HOSTNAME"}
defined $opt{"HOSTNAME"}
length $opt{"HOSTNAME"}
Truth table0%0/4
A and B and C
A= exists $opt{"HOSTNAME"}B= defined $opt{"HOSTNAME"}C= length $opt{"HOSTNAME"}
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $HOSTNAME = $opt{'HOSTNAME'}; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | delete $opt{'HOSTNAME'}; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | # Debugging info... | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 126 | warn 'Letting POE::Component::Server::SimpleHTTP create a default HOSTNAME'; | ||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | # Set the default | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $HOSTNAME = undef; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | # Remove any lingering HOSTNAME | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ( exists $opt{'HOSTNAME'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | delete $opt{'HOSTNAME'}; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | # Get the MUSTUNDERSTAND | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if ( exists $opt{'MUSTUNDERSTAND'} and defined $opt{'MUSTUNDERSTAND'} and length( $opt{'MUSTUNDERSTAND'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $opt{"MUSTUNDERSTAND"} and defined $opt{"MUSTUNDERSTAND"} and length $opt{"MUSTUNDERSTAND"}
exists $opt{"MUSTUNDERSTAND"} and defined $opt{"MUSTUNDERSTAND"}
MC/DC0%0/3
exists $opt{"MUSTUNDERSTAND"} and defined $opt{"MUSTUNDERSTAND"} and length $opt{"MUSTUNDERSTAND"}
exists $opt{"MUSTUNDERSTAND"}
defined $opt{"MUSTUNDERSTAND"}
length $opt{"MUSTUNDERSTAND"}
Truth table0%0/4
A and B and C
A= exists $opt{"MUSTUNDERSTAND"}B= defined $opt{"MUSTUNDERSTAND"}C= length $opt{"MUSTUNDERSTAND"}
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $MUSTUNDERSTAND = $opt{'MUSTUNDERSTAND'}; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | delete $opt{'MUSTUNDERSTAND'}; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # Debugging info... | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 145 | warn 'Using default MUSTUNDERSTAND ( 1 )'; | ||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | # Set the default | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $MUSTUNDERSTAND = 1; | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # Remove any lingering MUSTUNDERSTAND | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if ( exists $opt{'MUSTUNDERSTAND'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | delete $opt{'MUSTUNDERSTAND'}; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | # Get the SIMPLEHTTP | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if ( exists $opt{'SIMPLEHTTP'} and defined $opt{'SIMPLEHTTP'} and ref( $opt{'SIMPLEHTTP'} ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $opt{"SIMPLEHTTP"} and defined $opt{"SIMPLEHTTP"} and ref $opt{"SIMPLEHTTP"} eq "HASH"
exists $opt{"SIMPLEHTTP"} and defined $opt{"SIMPLEHTTP"}
MC/DC0%0/3
exists $opt{"SIMPLEHTTP"} and defined $opt{"SIMPLEHTTP"} and ref $opt{"SIMPLEHTTP"} eq "HASH"
exists $opt{"SIMPLEHTTP"}
defined $opt{"SIMPLEHTTP"}
ref $opt{"SIMPLEHTTP"} eq "HASH"
Truth table0%0/4
A and B and C
A= exists $opt{"SIMPLEHTTP"}B= defined $opt{"SIMPLEHTTP"}C= ref $opt{"SIMPLEHTTP"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $SIMPLEHTTP = $opt{'SIMPLEHTTP'}; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | delete $opt{'SIMPLEHTTP'}; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | # Anything left over is unrecognized | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 165 | if ( keys %opt > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | croak( 'Unrecognized options were present in POE::Component::Server::SOAP->new -> ' . join( ', ', keys %opt ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | # Create the POE Session! | ||||||||||||||||||||||||||||||||||||||||||
| 171 | POE::Session->create( | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 'inline_states' => { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | # Generic stuff | ||||||||||||||||||||||||||||||||||||||||||
| 174 | '_start' => \&StartServer, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | '_stop' => sub {}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | '_child' => \&SmartShutdown, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | # Shuts down the server | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 'SHUTDOWN' => \&StopServer, | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 'STOPLISTEN' => \&StopListen, | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 'STARTLISTEN' => \&StartListen, | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | # Adds/deletes Methods | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 'ADDMETHOD' => \&AddMethod, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 'DELMETHOD' => \&DeleteMethod, | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 'DELSERVICE' => \&DeleteService, | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | # Transaction handlers | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 'Got_Request' => \&TransactionStart, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 'FAULT' => \&TransactionFault, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 'RAWFAULT' => \&TransactionFault, | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 'DONE' => \&TransactionDone, | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 'RAWDONE' => \&TransactionDone, | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 'CLOSE' => \&TransactionClose, | ||||||||||||||||||||||||||||||||||||||||||
| 195 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | # Our own heap | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 'heap' => { | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 'INTERFACES' => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 'ALIAS' => $ALIAS, | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 'ADDRESS' => $ADDRESS, | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 'PORT' => $PORT, | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 'HEADERS' => $HEADERS, | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 'HOSTNAME' => $HOSTNAME, | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 'MUSTUNDERSTAND' => $MUSTUNDERSTAND, | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 'SIMPLEHTTP' => $SIMPLEHTTP, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 208 | ) or die 'Unable to create a new session!'; | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | # Return success | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | # Creates the server | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub StartServer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StartServer: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | # Set the alias | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $_[KERNEL]->alias_set( $_[HEAP]->{'ALIAS'} ); | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | # Create the webserver! | ||||||||||||||||||||||||||||||||||||||||||
| 220 | POE::Component::Server::SimpleHTTP->new( | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 'ALIAS' => $_[HEAP]->{'ALIAS'} . '-BACKEND', | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 'ADDRESS' => $_[HEAP]->{'ADDRESS'}, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 'PORT' => $_[HEAP]->{'PORT'}, | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 'HOSTNAME' => $_[HEAP]->{'HOSTNAME'}, | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 'HEADERS' => $_[HEAP]->{'HEADERS'}, | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 'HANDLERS' => [ | ||||||||||||||||||||||||||||||||||||||||||
| 227 | { | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 'DIR' => '.*', | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 'SESSION' => $_[HEAP]->{'ALIAS'}, | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 'EVENT' => 'Got_Request', | ||||||||||||||||||||||||||||||||||||||||||
| 231 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 232 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | ( defined $_[HEAP]->{'SIMPLEHTTP'} ? ( %{ $_[HEAP]->{'SIMPLEHTTP'} } ) : () ), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | ) or die 'Unable to create the HTTP Server'; | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | # Success! | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | # Shuts down the server | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub StopServer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StopServer: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | # Tell the webserver to die! | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if ( defined $_[ARG0] and $_[ARG0] eq 'GRACEFUL' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[10] and $_[10] eq "GRACEFUL"
MC/DC0%0/2
defined $_[10] and $_[10] eq "GRACEFUL"
defined $_[10]
$_[10] eq "GRACEFUL"
Truth table0%0/3
A and B
A= defined $_[10]B= $_[10] eq "GRACEFUL"
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | # Shutdown gently... | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $_[KERNEL]->call( $_[HEAP]->{'ALIAS'} . '-BACKEND', 'SHUTDOWN', 'GRACEFUL' ); | |||||||||||||||||||||||||||||||||||||||||
| 246 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 247 | # Shutdown NOW! | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $_[KERNEL]->call( $_[HEAP]->{'ALIAS'} . '-BACKEND', 'SHUTDOWN' ); | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | # Success! | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # Stops listening for connections | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub StopListen { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StopListen: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | # Tell the webserver this! | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $_[KERNEL]->call( $_[HEAP]->{'ALIAS'} . '-BACKEND', 'STOPLISTEN' ); | |||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | # Success! | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | # Starts listening for connections | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub StartListen { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StartListen: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | # Tell the webserver this! | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $_[KERNEL]->call( $_[HEAP]->{'ALIAS'} . '-BACKEND', 'STARTLISTEN' ); | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | # Success! | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | # Watches for SimpleHTTP shutting down and shuts down ourself | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | sub SmartShutdown { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SmartShutdown: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | # ARG0 = type, ARG1 = ref to session, ARG2 = parameters | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # Check for real shutdown | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | if ( $_[ARG0] eq 'lose' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | # Remove our alias | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $_[KERNEL]->alias_remove( $_[HEAP]->{'ALIAS'} ); | |||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | # Debug stuff | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 284 | warn 'Received _child event from SimpleHTTP, shutting down'; | ||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | # All done! | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | # Adds a method | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | sub AddMethod { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AddMethod: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | # ARG0: Session alias, ARG1: Session event, ARG2: Service name, ARG3: Method name | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my( $alias, $event, $service, $method ); | |||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | # Check for stuff! | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if ( defined $_[ARG0] and length( $_[ARG0] ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[10] and length $_[10]
MC/DC0%0/2
defined $_[10] and length $_[10]
defined $_[10]
length $_[10]
Truth table0%0/3
A and B
A= defined $_[10]B= length $_[10]
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $alias = $_[ARG0]; | |||||||||||||||||||||||||||||||||||||||||
| 300 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | # Complain! | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 303 | warn 'Did not get a Session Alias'; | ||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if ( defined $_[ARG1] and length( $_[ARG1] ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[11] and length $_[11]
MC/DC0%0/2
defined $_[11] and length $_[11]
defined $_[11]
length $_[11]
Truth table0%0/3
A and B
A= defined $_[11]B= length $_[11]
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $event = $_[ARG1]; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 311 | # Complain! | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 313 | warn 'Did not get a Session Event'; | ||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | # If none, defaults to the Session stuff | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if ( defined $_[ARG2] and length( $_[ARG2] ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[12] and length $_[12]
MC/DC0%0/2
defined $_[12] and length $_[12]
defined $_[12]
length $_[12]
Truth table0%0/3
A and B
A= defined $_[12]B= length $_[12]
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $service = $_[ARG2]; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 322 | # Debugging stuff | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 324 | warn 'Using Session Alias as Service Name'; | ||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $service = $alias; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ( defined $_[ARG3] and length( $_[ARG3] ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[13] and length $_[13]
MC/DC0%0/2
defined $_[13] and length $_[13]
defined $_[13]
length $_[13]
Truth table0%0/3
A and B
A= defined $_[13]B= length $_[13]
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $method = $_[ARG3]; | |||||||||||||||||||||||||||||||||||||||||
| 332 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 333 | # Debugging stuff | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 335 | warn 'Using Session Event as Method Name'; | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $method = $event; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | # If we are debugging, check if we overwrote another method | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 343 | if ( exists $_[HEAP]->{'INTERFACES'}->{ $service } ) { | ||||||||||||||||||||||||||||||||||||||||||
| 344 | if ( exists $_[HEAP]->{'INTERFACES'}->{ $service }->{ $method } ) { | ||||||||||||||||||||||||||||||||||||||||||
| 345 | warn 'Overwriting old method entry in the registry ( ' . $service . ' -> ' . $method . ' )'; | ||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | # Add it to our INTERFACES | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $_[HEAP]->{'INTERFACES'}->{ $service }->{ $method } = [ $alias, $event ]; | |||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | # Return success | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | # Deletes a method | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | sub DeleteMethod { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DeleteMethod: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | # ARG0: Service name, ARG1: Service method name | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my( $service, $method ) = @_[ ARG0, ARG1 ]; | |||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | # Validation | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if ( defined $service and length( $service ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $service and length $service
MC/DC0%0/2
defined $service and length $service
defined $service
length $service
Truth table0%0/3
A and B
A= defined $serviceB= length $service
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | # Validation | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | if ( defined $method and length( $method ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $method and length $method
MC/DC0%0/2
defined $method and length $method
defined $method
length $method
Truth table0%0/3
A and B
A= defined $methodB= length $method
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | # Validation | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | if ( exists $_[HEAP]->{'INTERFACES'}->{ $service }->{ $method } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | # Delete it! | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | delete $_[HEAP]->{'INTERFACES'}->{ $service }->{ $method }; | |||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | # Check to see if the service now have no methods | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if ( keys( %{ $_[HEAP]->{'INTERFACES'}->{ $service } } ) == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | # Debug stuff | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 375 | warn "Service $service contains no methods, removing it!"; | ||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | # Delete it! | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | delete $_[HEAP]->{'INTERFACES'}->{ $service }; | |||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | # Return success | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 384 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 385 | # Error! | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 387 | warn 'Tried to delete a nonexistant Method in Service -> ' . $service . ' : ' . $method; | ||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 391 | # Complain! | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 393 | warn 'Did not get a method to delete in Service -> ' . $service; | ||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 397 | # No arguments! | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 399 | warn 'Received no arguments!'; | ||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | # Deletes a service | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub DeleteService { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DeleteService: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | # ARG0: Service name | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my( $service ) = $_[ ARG0 ]; | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | # Validation | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | if ( defined $service and length( $service ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $service and length $service
MC/DC0%0/2
defined $service and length $service
defined $service
length $service
Truth table0%0/3
A and B
A= defined $serviceB= length $service
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | # Validation | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if ( exists $_[HEAP]->{'INTERFACES'}->{ $service } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | # Delete it! | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | delete $_[HEAP]->{'INTERFACES'}->{ $service }; | |||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | # Return success! | ||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 420 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 421 | # Error! | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 423 | warn 'Tried to delete a Service that does not exist! -> ' . $service; | ||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 427 | # No arguments! | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 429 | warn 'Received no arguments!'; | ||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | # Got a request, handle it! | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | sub TransactionStart { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TransactionStart: not called CC=20 SCAR=60.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | # ARG0 = HTTP::Request, ARG1 = HTTP::Response, ARG2 = dir that matched | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my ( $request, $response ) = @_[ ARG0, ARG1 ]; | |||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | # Check for error in parsing of request | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | if ( ! defined $request ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | # Create a new error and send it off! | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 445 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 446 | $SOAP::Constants::FAULT_CLIENT, | ||||||||||||||||||||||||||||||||||||||||||
| 447 | 'Bad Request', | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 'Unable to parse HTTP query', | ||||||||||||||||||||||||||||||||||||||||||
| 449 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | # We only handle text/xml content | ||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ( ! $request->header('Content-Type') || $request->header('Content-Type') !~ /^text\/xml(;.*)?$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$request->header("Content-Type") and $request->header("Content-Type") =~ m[^text/xml(;.*)?$]
MC/DC0%0/2
$request->header("Content-Type") and $request->header("Content-Type") =~ m[^text/xml(;.*)?$]
$request->header("Content-Type")
$request->header("Content-Type") =~ m[^text/xml(;.*)?$]
Truth table0%0/3
A and B
A= $request->header("Content-Type")B= $request->header("Content-Type") =~ m[^text/xml(;.*)?$]
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | # Create a new error and send it off! | ||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 457 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 458 | $SOAP::Constants::FAULT_CLIENT, | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 'Bad Request', | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 'Content-Type must be text/xml', | ||||||||||||||||||||||||||||||||||||||||||
| 461 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | # We need the method name | ||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my $soap_method_name = $request->header('SOAPAction'); | |||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if ( ! defined $soap_method_name or ! length( $soap_method_name ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $soap_method_name and length $soap_method_name
MC/DC0%0/2
defined $soap_method_name and length $soap_method_name
defined $soap_method_name
length $soap_method_name
Truth table0%0/3
A and B
A= defined $soap_method_nameB= length $soap_method_name
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | # Create a new error and send it off! | ||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 470 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 471 | $SOAP::Constants::FAULT_CLIENT, | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 'Bad Request', | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 'SOAPAction is required', | ||||||||||||||||||||||||||||||||||||||||||
| 474 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | # Get some stuff | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $query_string = $request->uri->query(); | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | if ( ! defined $query_string or $query_string !~ /\bsession=(.+ $ )/x ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $query_string and $query_string =~ /\bsession=(.+ $ )/x
MC/DC0%0/2
defined $query_string and $query_string =~ /\bsession=(.+ $ )/x
defined $query_string
$query_string =~ /\bsession=(.+ $ )/x
Truth table0%0/3
A and B
A= defined $query_stringB= $query_string =~ /\bsession=(.+ $ )/x
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | # Create a new error and send it off! | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 483 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 484 | $SOAP::Constants::FAULT_CLIENT, | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 'Bad Request', | ||||||||||||||||||||||||||||||||||||||||||
| 486 | 'Unable to parse the URI for the service', | ||||||||||||||||||||||||||||||||||||||||||
| 487 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | # Get the service | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $service = $1; | |||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | # Check to see if this service exists | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | if ( ! exists $_[HEAP]->{'INTERFACES'}->{ $service } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | # Create a new error and send it off! | ||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 498 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 499 | $SOAP::Constants::FAULT_CLIENT, | ||||||||||||||||||||||||||||||||||||||||||
| 500 | 'Bad Request', | ||||||||||||||||||||||||||||||||||||||||||
| 501 | "Unknown service: $service", | ||||||||||||||||||||||||||||||||||||||||||
| 502 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | # Get the method name | ||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if ( $soap_method_name !~ /^([\"\']?)(\S+)\#(\S+)\1$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | # Create a new error and send it off! | ||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 510 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 511 | $SOAP::Constants::FAULT_CLIENT, | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 'Bad Request', | ||||||||||||||||||||||||||||||||||||||||||
| 513 | "Unrecognized SOAPAction header: $soap_method_name", | ||||||||||||||||||||||||||||||||||||||||||
| 514 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | # Get the uri + method | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my $soapuri = $2; | |||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my $method = $3; | |||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | # Check to see if this method exists | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | if ( ! exists $_[HEAP]->{'INTERFACES'}->{ $service }->{ $method } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | # Create a new error and send it off! | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 526 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 527 | $SOAP::Constants::FAULT_CLIENT, | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 'Bad Request', | ||||||||||||||||||||||||||||||||||||||||||
| 529 | "Unknown method: $method", | ||||||||||||||||||||||||||||||||||||||||||
| 530 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | # Actually parse the SOAP query! | ||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $som_object; | |||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | eval { $som_object = SOAP::Deserializer->deserialize( $request->content() ) }; ## no critic ( RequireExplicitInclusion ) | |||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | # Check for errors | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | # Check for special case: VERSION_MISMATCH | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | if ( $@ =~ /^$SOAP::Constants::WRONG_VERSION/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | # Create a version mismatch Fault | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 544 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 545 | $SOAP::Constants::FAULT_VERSION_MISMATCH, | ||||||||||||||||||||||||||||||||||||||||||
| 546 | $SOAP::Constants::WRONG_VERSION, | ||||||||||||||||||||||||||||||||||||||||||
| 547 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 548 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 549 | # Create a new error and send it off! | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 551 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 552 | $SOAP::Constants::FAULT_SERVER, | ||||||||||||||||||||||||||||||||||||||||||
| 553 | 'Application Faulted', | ||||||||||||||||||||||||||||||||||||||||||
| 554 | "Failed while unmarshaling the request: $@", | ||||||||||||||||||||||||||||||||||||||||||
| 555 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | # All done! | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | # Check the headers for the mustUnderstand attribute, and Fault if it is present | ||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $head_count = 1; | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my @headers = (); | |||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | while ( 1 ) { | |||||||||||||||||||||||||||||||||||||||||
| 566 | # Get the header | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $hdr = $som_object->headerof( SOAP::SOM::header . "/[$head_count]" ); ## no critic ( RequireExplicitInclusion ) | |||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | # Check if it is defined | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | if ( ! defined $hdr ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | # We ran out of headers | ||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | # Check if it have mustUnderstand | ||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if ( $_[HEAP]->{'MUSTUNDERSTAND'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if ( $hdr->mustUnderstand ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | # Fault! | ||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | $_[KERNEL]->yield( 'FAULT', | |||||||||||||||||||||||||||||||||||||||||
| 580 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 581 | $SOAP::Constants::FAULT_MUST_UNDERSTAND, | ||||||||||||||||||||||||||||||||||||||||||
| 582 | "Unrecognized header '" . $hdr->name . "' has mustUnderstand set to 'true'", | ||||||||||||||||||||||||||||||||||||||||||
| 583 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | # We're done... | ||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | # Push it into the headers array | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | push( @headers, $hdr ); | |||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | # Increment the counter | ||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $head_count++; | |||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | # Extract the body | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my $body = $som_object->body(); | |||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | # Remove the top-level method name in the body | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $body = $body->{ $method }; | |||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | # If it is an empty string, turn it into undef | ||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | if ( defined $body and ! ref( $body ) and $body eq '' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $body and not ref $body and $body eq ""
defined $body and not ref $body
MC/DC0%0/3
defined $body and not ref $body and $body eq ""
defined $body
not ref $body
$body eq ""
Truth table0%0/4
A and not(B) and C
A= defined $bodyB= not ref $bodyC= $body eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $body = undef; | |||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | # Hax0r the Response to include our stuff! | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $response->{'SOAPMETHOD'} = $method; | |||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $response->{'SOAPBODY'} = $body; | |||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $response->{'SOAPSERVICE'} = $service; | |||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | $response->{'SOAPREQUEST'} = $request; | |||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | $response->{'SOAPURI'} = $soapuri; | |||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | # Make the headers undef if there is none | ||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | if ( scalar( @headers ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | $response->{'SOAPHEADERS'} = \@headers; | |||||||||||||||||||||||||||||||||||||||||
| 618 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | $response->{'SOAPHEADERS'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | # ReBless it ;) | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | bless( $response, 'POE::Component::Server::SOAP::Response' ); | |||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | # Send it off to the handler! | ||||||||||||||||||||||||||||||||||||||||||
| 626 | $_[KERNEL]->post( $_[HEAP]->{'INTERFACES'}->{ $service }->{ $method }->[0], | ||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | $_[HEAP]->{'INTERFACES'}->{ $service }->{ $method }->[1], | |||||||||||||||||||||||||||||||||||||||||
| 628 | $response, | ||||||||||||||||||||||||||||||||||||||||||
| 629 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | # Debugging stuff | ||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 633 | warn "Sending off to the handler: Service $service -> Method $method for " . $response->connection->remote_ip(); | ||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | if ( DEBUG == 2 ) { | |||||||||||||||||||||||||||||||||||||||||
| 637 | print STDERR $request->content(), "\n\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | # All done! | ||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | # Creates the fault and sends it off | ||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | sub TransactionFault { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TransactionFault: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 646 | # ARG0 = SOAP::Response, ARG1 = SOAP faultcode, ARG2 = SOAP faultstring, ARG3 = SOAP Fault Detail, ARG4 = SOAP Fault Actor | ||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my ( $response, $fault_code, $fault_string, $fault_detail, $fault_actor ) = @_[ ARG0 .. ARG4 ]; | |||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | # Make sure we have a SOAP::Response object here :) | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | if ( ! defined $response ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | # Debug stuff | ||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 653 | warn 'Received FAULT event but no arguments!'; | ||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | # Is this a RAWFAULT event? | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my $content = undef; | |||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | if ( $_[STATE] eq 'RAWFAULT' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 661 | # Tell SOAP::Serializer to not serialize it | ||||||||||||||||||||||||||||||||||||||||||
| 662 | ## no critic ( RequireExplicitInclusion ) | ||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $content = SOAP::Serializer->envelope( 'freeform', SOAP::Data->type( 'xml', $response->content() ) ); | |||||||||||||||||||||||||||||||||||||||||
| 664 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 665 | # Fault Code must be defined | ||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if ( ! defined $fault_code or ! length( $fault_code ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fault_code and length $fault_code
MC/DC0%0/2
defined $fault_code and length $fault_code
defined $fault_code
length $fault_code
Truth table0%0/3
A and B
A= defined $fault_codeB= length $fault_code
| |||||||||||||||||||||||||||||||||||||||||||
| 667 | # Debug stuff | ||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 669 | warn 'Setting default Fault Code'; | ||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | # Set the default | ||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | $fault_code = $SOAP::Constants::FAULT_SERVER; | |||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | # FaultString is a short description of the error | ||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | if ( ! defined $fault_string or ! length( $fault_string ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fault_string and length $fault_string
MC/DC0%0/2
defined $fault_string and length $fault_string
defined $fault_string
length $fault_string
Truth table0%0/3
A and B
A= defined $fault_stringB= length $fault_string
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | # Debug stuff | ||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 680 | warn 'Setting default Fault String'; | ||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | # Set the default | ||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | $fault_string = 'Application Faulted'; | |||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | # Serialize the envelope | ||||||||||||||||||||||||||||||||||||||||||
| 688 | ## no critic ( RequireExplicitInclusion ) | ||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $content = SOAP::Serializer->envelope( 'fault', $fault_code, $fault_string, $fault_detail, $fault_actor ); | |||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||
| 692 | # Setup the response | ||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if ( ! defined $response->code ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $response->code( $SOAP::Constants::HTTP_ON_FAULT_CODE ); | |||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $response->header( 'Content-Type', 'text/xml' ); | |||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $response->content( $content ); | |||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | # Send it off to the backend! | ||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | $_[KERNEL]->post( $_[HEAP]->{'ALIAS'} . '-BACKEND', 'DONE', $response ); | |||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | # Debugging stuff | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 704 | warn 'Finished processing ' . $_[STATE] . ' for ' . $response->connection->remote_ip(); | ||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | if ( DEBUG == 2 ) { | |||||||||||||||||||||||||||||||||||||||||
| 708 | print STDERR "$content\n\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | # All done! | ||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | # All done with a transaction! | ||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | sub TransactionDone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TransactionDone: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | # ARG0 = SOAP::Response object | ||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my $response = $_[ARG0]; | |||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | # Make the envelope! | ||||||||||||||||||||||||||||||||||||||||||
| 721 | # The prefix is to change the darned "c-gensym3" to "s-gensym3" -> means it was server-generated ( whatever SOAP::Lite says... ) | ||||||||||||||||||||||||||||||||||||||||||
| 722 | ## no critic ( RequireExplicitInclusion ) | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | my $content = SOAP::Serializer->prefix( 's' )->envelope( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 'response', | ||||||||||||||||||||||||||||||||||||||||||
| 725 | SOAP::Data->name( $response->soapmethod() . 'Response' )->uri( $response->soapuri() ), | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | # Do we need to serialize the content or not? | ||||||||||||||||||||||||||||||||||||||||||
| 728 | ( $_[STATE] eq 'RAWDONE' ? SOAP::Data->type( 'xml', $response->content() ) : $response->content() ), | ||||||||||||||||||||||||||||||||||||||||||
| 729 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 730 | ## use critic | ||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | # Set up the response! | ||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | if ( ! defined $response->code ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | $response->code( $SOAP::Constants::HTTP_ON_SUCCESS_CODE ); | |||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | $response->header( 'Content-Type', 'text/xml' ); | |||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $response->content( $content ); | |||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | # Send it off! | ||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | $_[KERNEL]->post( $_[HEAP]->{'ALIAS'} . '-BACKEND', 'DONE', $response ); | |||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | # Debug stuff | ||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 744 | warn 'Finished processing ' . $_[STATE] . ' Service ' . $response->soapservice . ' -> Method ' . $response->soapmethod . ' for ' . $response->connection->remote_ip(); | ||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | if ( DEBUG == 2 ) { | |||||||||||||||||||||||||||||||||||||||||
| 748 | print STDERR "$content\n\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | # All done! | ||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | # Close the transaction | ||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | sub TransactionClose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TransactionClose: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 757 | # ARG0 = SOAP::Response object | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | my $response = $_[ARG0]; | |||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | # Send it off to the backend, signaling CLOSE | ||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $_[KERNEL]->post( $_[HEAP]->{'ALIAS'} . '-BACKEND', 'CLOSE', $response ); | |||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | # Debug stuff | ||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | if ( DEBUG ) { | |||||||||||||||||||||||||||||||||||||||||
| 765 | warn 'Closing the socket of this Service ' . $response->soapmethod . ' -> Method ' . $response->soapmethod() . ' for ' . $response->connection->remote_ip(); | ||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | # All done! | ||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 773 | __END__ | ||||||||||||||||||||||||||||||||||||||||||