File Coverage

lib/XML/Compile/SOAP12/Server.pm
Criterion Covered Total %
statement 24 66 36.3
branch 0 4 0.0
condition 0 13 0.0
subroutine 8 16 50.0
pod 0 8 0.0
total 32 107 29.9


line stmt bran cond sub pod time code
1             # Copyrights 2009-2018 by [Mark Overmeer ].
2             # For other contributors see ChangeLog.
3             # See the manual pages for details on the licensing terms.
4             # Pod stripped from pm file by OODoc 2.02.
5             # This code is part of distribution XML-Compile-SOAP12. Meta-POD processed
6             # with OODoc into POD and HTML manual-pages. See README.md
7             # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8              
9             package XML::Compile::SOAP12::Server;
10 1     1   7 use vars '$VERSION';
  1         2  
  1         54  
11             $VERSION = '3.06';
12              
13 1     1   5 use base 'XML::Compile::SOAP12', 'XML::Compile::SOAP::Server';
  1         2  
  1         520  
14              
15 1     1   6468 use warnings;
  1         3  
  1         25  
16 1     1   5 use strict;
  1         2  
  1         21  
17              
18 1     1   5 use Log::Report 'xml-compile-soap';
  1         1  
  1         7  
19              
20 1     1   237 use XML::Compile::Util qw/pack_type unpack_type SCHEMA2001/;
  1         2  
  1         53  
21 1     1   6 use XML::Compile::SOAP::Util qw/XC_DAEMON_NS/;
  1         2  
  1         42  
22 1     1   5 use XML::Compile::SOAP12::Util qw/SOAP12ENV SOAP12NEXT/;
  1         2  
  1         636  
23              
24              
25             sub init($)
26 0     0 0   { my ($self, $args) = @_;
27 0           $self->XML::Compile::SOAP12::init($args);
28 0           $self->XML::Compile::SOAP::Server::init($args);
29 0           $self;
30             }
31              
32             sub makeError(@)
33 0     0 0   { my ($self, %args) = @_;
34              
35 0           my %error;
36 0   0       $error{Role} = $args{Role} || $args{faultactor};
37 0   0       $error{Detail} = $args{Detail} || $args{detail};
38              
39             $error{Code} = $args{Code}
40             || { Value => pack_type(SOAP12ENV, 'Receiver')
41             , Subcode => { Value => $args{faultcode} }
42 0   0       };
43              
44             $error{Reason} = $args{Reason}
45 0   0       || { Text => [ { lang => 'en', _ => $args{faultstring} } ] };
46              
47 0           info "Fault: $error{Reason}{Text}[0]{_}";
48 0           $self->faultWriter->(Fault => \%error);
49             }
50              
51             sub faultValidationFailed($$)
52 0     0 0   { my ($self, $name, $exception) = @_;
53              
54 0           my $message =
55             __x"operation {name} for {version} called with invalid data"
56             , name => $name, version => 'SOAP12';
57              
58 0           my $errors = XML::LibXML::Element->new('error');
59 0           $errors->appendText($exception->message->toString);
60 0           my $detail = XML::LibXML::Element->new('detail');
61 0           $detail->addChild($errors);
62              
63 0           $self->makeError
64             ( faultcode => pack_type(XC_DAEMON_NS, 'validationFailed')
65             , faultstring => $message
66             , faultactor => $self->role
67             , detail => $detail
68             );
69             }
70              
71             sub faultResponseInvalid($$)
72 0     0 0   { my ($self, $name, $exception) = @_;
73              
74 0           my $message =
75             __x"procedure {name} for {version} produced an invalid response"
76             , name => $name, version => 'SOAP12';
77              
78             # Namespace qualified?
79 0           my $errors = XML::LibXML::Element->new('error');
80 0           $errors->appendText($exception->message->toString);
81 0           my $detail = XML::LibXML::Element->new('Detail');
82 0           $detail->addChild($errors);
83              
84 0           $self->makeError
85             ( faultcode => pack_type(XC_DAEMON_NS, 'invalidResponse')
86             , faultstring => $message
87             , faultactor => $self->role
88             , detail => $detail
89             );
90             }
91              
92             sub faultNotImplemented($)
93 0     0 0   { my ($self, $name) = @_;
94              
95 0           my $message = __x"procedure {name} for {version} is not yet implemented"
96             , name => $name, version => 'SOAP12';
97              
98 0           $self->makeError
99             ( faultcode => pack_type(XC_DAEMON_NS, 'notImplemented')
100             , faultstring => $message
101             , faultactor => SOAP12NEXT
102             );
103             }
104              
105             sub faultNoAnswerProduced($)
106 0     0 0   { my ($self, $name) = @_;
107            
108 0           my $message = __x"callback {name} did not return an answer", name => $name;
109 0           $self->makeError
110             ( faultcode => pack_type(XC_DAEMON_NS, 'noAnswerProduced')
111             , faultstring => $message
112             , faultactor => $self->role
113             );
114             }
115              
116             sub faultMessageNotRecognized($$$)
117 0     0 0   { my ($self, $name, $action, $handlers) = @_;
118              
119 0           my $message;
120 0 0 0       if($handlers && @$handlers)
121 0 0         { my $sa = $action ? " (soapAction $action)" : '';
122 0           $message = __x"{version} body element {name}{sa} not recognized, available ports are {def}"
123             , version => 'SOAP12', name => $name, sa => $sa, def => $handlers;
124             }
125             else
126 0           { $message =
127             __x"{version} there are no handlers available, so also not for {name}"
128             , version => 'SOAP12', name => $name;
129             }
130              
131 0           $self->makeError
132             ( faultcode => pack_type(XC_DAEMON_NS, 'notRecognized')
133             , faultstring => $message
134             , faultactor => SOAP12NEXT
135             );
136             }
137              
138             sub faultTryOtherProtocol($$)
139 0     0 0   { my ($self, $name, $other) = @_;
140              
141 0           my $message =
142             __x"body element {name} not available in {version}, try {other}"
143             , name => $name, version => 'SOAP12', other => $other;
144              
145 0           $self->makeError
146             ( faultcode => pack_type(XC_DAEMON_NS, 'tryUpgrade')
147             , faultstring => $message
148             , faultactor => SOAP12NEXT
149             );
150             }
151              
152             1;