File Coverage

blib/lib/SOAPjr.pm
Criterion Covered Total %
statement 15 26 57.6
branch n/a
condition n/a
subroutine 5 8 62.5
pod 2 2 100.0
total 22 36 61.1


line stmt bran cond sub pod time code
1             package SOAPjr;
2              
3 1     1   25066 use strict;
  1         3  
  1         45  
4 1     1   6 use warnings;
  1         3  
  1         35  
5 1     1   7 use base qw(SOAPjr::base);
  1         6  
  1         640  
6              
7 1     1   606 use SOAPjr::request;
  1         3  
  1         32  
8 1     1   545 use SOAPjr::response;
  1         3  
  1         198  
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             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             sub _init {
92 0     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             sub create_request {
105 0     0 1   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             sub create_response {
118 0     0 1   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,
126              
127             =head1 BUGS
128              
129             Please report any bugs or feature requests to C, or through
130             the web interface at L. 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
150              
151             =item * RT: CPAN's request tracker
152              
153             L
154              
155             =item * AnnoCPAN: Annotated CPAN documentation
156              
157             L
158              
159             =item * CPAN Ratings
160              
161             L
162              
163             =item * Search CPAN
164              
165             L
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 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 .
197              
198             =cut
199              
200             1; # End of SOAPjr