SOAPjr.pm

filter: Statementstmt 60.7% 17 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 5 / 8 Podpod 100% 2 / 2 totaltotal 63.1% 24 / 38 CC 1 SCAR 3.2
CC
1
Cov
61%
_init
2.0
create_request
2.0
create_response
2.0
CRAP 1.4
« SOAPjr/response.pm ↑ Summary SOAPjr/message.pm »
1 package SOAPjr;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base qw(SOAPjr::base);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use SOAPjr::request;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use SOAPjr::response;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 SOAPjr - SOAP without the bloat and JR (JSON-RPC) with proper error handling and file uploads
13  
14 =head1 VERSION
15  
16 Version 1.1.4
17  
18 =cut
19  
20 1 our $VERSION = "1.1.4";
21  
22 =head1 SYNOPSIS
23  
24 Overview
25 --------
26 1. Receive request message
27 2. Validate request message
28 3. Process request message
29 4. Create response message
30 5. Configure response message
31 6. Send response message
32  
33 # The assumption is that this module will be used from within a perl script (or an apache request handler)
34 # - use in the module
35 use SOAPjr;
36  
37 # - create the SOAPjr server object
38 # NOTE: This is the equivalent of jquery on the client side and may be created in the apache perl_startup.pl script so it's persistent
39 my $server = SOAPjr->new($options);
40
41 # 1. Receive request message
42 # - your perl script is called either directly or as a handler
43 # e.g. /SOAPjr.pl
44  
45 # 2. Validate request message
46 # - create the inbound request object for this request
47 my $request = $server->create_request($query_params_hashref, \%ENV);
48
49 # - set any settings for this inbound request object
50 $request->set({ OPTIONS => { "..." => "..." } });
51
52 # 3. Process request message
53 # This is where your development implementation happens
54 # - process the request however you need to
55 # ...
56
57 # 4. Create response message
58 # - then when you're ready you create a response object
59 my $response = $self->create_response({ ENVELOPE => { "option1" => "XXX" } });
60
61 # 5. Configure response message
62 # - then set any of the response values
63 $response->set({ HEAD => { "option1" => "DDD" }, BODY => { "option1" => "LLL" } });
64  
65 # 6. Add any errors you need to
66 # - if your processing of $request creates any errors then just add them with $response->add_error()
67 # e.g.
68 # $s = $r->add_error({
69 # context => "HEAD",
70 # property => "sid",
71 # error => {
72 # code => 401,
73 # message => "Invalid session ID"
74 # }
75 # });
76 # NOTE: $s (e.g. the return of add_error()) is a serialised_string of the current object after the error is added
77
78 # 7. Send response message
79 # - then when you're done you send back your response
80 my $send_result = $response->send({ HEAD => { "option1" => "DDD" }, BODY => { "option1" => "LLL" } });
81 # or you can just get a serialised string of the object at any time using $response->output();
82  
83 =head1 FUNCTIONS
84  
85 =head2 _init
86  
87 Private method to enable inheritance via SOAPjr::base.
88  
89 =cut
90  
91 0 ▶sub _init {
Subroutine _init: not called CC=1 SCAR=6.9
92 0 my $self = shift;
93 0 my $input = shift;
94 0 $self->set($input);
95 0 return $self->SUPER::_init($input);
96 }
97  
98 =head2 create_request
99  
100 Public method to enable the creation of a SOAPjr request object.
101  
102 =cut
103  
104 0 ▶sub create_request {
Subroutine create_request: not called CC=1 SCAR=6.9
Pod documented
105 0 my $self = shift;
106 0 my $query = shift;
107 0 my $SOAPjr_request = SOAPjr::request->new($self, $query, @_);
108 0 return $SOAPjr_request;
109 }
110  
111 =head2 create_response
112  
113 Public method to enable the creation of a SOAPjr response object.
114  
115 =cut
116  
117 0 ▶sub create_response {
Subroutine create_response: not called CC=1 SCAR=6.9
Pod documented
118 0 my $self = shift;
119 0 my $SOAPjr_response = SOAPjr::response->new(@_);
120 0 return $SOAPjr_response;
121 }
122  
123 =head1 AUTHOR
124  
125 Rob Manson, <robman[at]cpan.org>
126  
127 =head1 BUGS
128  
129 Please report any bugs or feature requests to C<bug-soapjr at rt.cpan.org>, or through
130 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SOAPjr>. I will be notified, and then you'll
131 automatically be notified of progress on your bug as I make changes.
132  
133  
134  
135  
136 =head1 SUPPORT
137  
138 You can find documentation for this module with the perldoc command.
139  
140 perldoc SOAPjr
141  
142  
143 You can also look for information at:
144  
145 =over 4
146  
147 =item * SOAPjr.org
148  
149 L<http://SOAPjr.org>
150  
151 =item * RT: CPAN's request tracker
152  
153 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=SOAPjr>
154  
155 =item * AnnoCPAN: Annotated CPAN documentation
156  
157 L<http://annocpan.org/dist/SOAPjr>
158  
159 =item * CPAN Ratings
160  
161 L<http://cpanratings.perl.org/d/SOAPjr>
162  
163 =item * Search CPAN
164  
165 L<http://search.cpan.org/dist/SOAPjr/>
166  
167 =back
168  
169 =head1 TODO
170  
171 Need to write t/ tests and add detailed documentation then replace t/pod-coverage.t.
172  
173 Also need to create Server and Client modules ala JSON::RPC and more detailed example scripts.
174  
175 =head1 ACKNOWLEDGEMENTS
176  
177 See L<http://SOAPjr.org/specs.html> for further information on related RFC's and specifications.
178  
179 =head1 COPYRIGHT & LICENSE
180  
181 Copyright 2008 Rob Manson, Sean McCarthy and http://SOAPjr.org, some rights reserved.
182  
183 This file is part of SOAPjr.
184  
185 SOAPjr is free software: you can redistribute it and/or modify
186 it under the terms of the GNU General Public License as published by
187 the Free Software Foundation, either version 3 of the License, or
188 (at your option) any later version.
189  
190 SOAPjr is distributed in the hope that it will be useful,
191 but WITHOUT ANY WARRANTY; without even the implied warranty of
192 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
193 GNU General Public License for more details.
194  
195 You should have received a copy of the GNU General Public License
196 along with SOAPjr. If not, see <http://www.gnu.org/licenses/>.
197  
198 =cut
199  
200 1 1; # End of SOAPjr
« SOAPjr/response.pm ↑ Summary SOAPjr/message.pm »