| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package POE::Filter::XML::RPC::Request; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
67
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
74
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1013
|
use POE::Filter::XML::Node; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use base('POE::Filter::XML::Node'); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new() |
|
13
|
|
|
|
|
|
|
{ |
|
14
|
|
|
|
|
|
|
my ($class, $methodname, $params) = @_; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $self = POE::Filter::XML::Node->new('methodCall'); |
|
17
|
|
|
|
|
|
|
$self->appendChild('methodName'); |
|
18
|
|
|
|
|
|
|
$self->appendChild('params'); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
bless($self, $class); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$self->method_name($methodname); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
if(defined($params) and ref($params) eq 'ARRAY') |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
|
|
|
|
|
|
foreach my $param (@$params) |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
|
|
|
|
|
|
$self->add_parameter($param); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return $self; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub method_name() |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
|
|
|
|
|
|
my ($self, $arg) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
if(defined($arg)) |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
|
|
|
|
|
|
($self->findnodes('child::methodName'))[0]->appendText($arg); |
|
42
|
|
|
|
|
|
|
return $arg; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} else { |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return $self->findvalue('child::methodName/child::text()'); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub parameters() |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
|
|
|
|
|
|
return [ map { bless($_, 'POE::Filter::XML::RPC::Value') } shift(@_)->findnodes('child::params/child::param/child::value') ]; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub add_parameter() |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
|
|
|
|
|
|
my ($self, $val) = @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$self->add($self->wrap($val)); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return bless($val, 'POE::Filter::XML::RPC::Value'); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub insert_parameter() |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
|
|
|
|
|
|
my ($self, $val, $index) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$self->insert($self->wrap($val), $index); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return bless($val, 'POE::Filter::XML::RPC::Value'); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub delete_parameter() |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
|
|
|
|
|
|
my ($self, $index) = @_; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $val = ($self->delete($index)->findnodes('child::value'))[0]; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
return bless($val, 'POE::Filter::XML::RPC::Value'); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub get_parameter() |
|
83
|
|
|
|
|
|
|
{ |
|
84
|
|
|
|
|
|
|
my ($self, $index) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $val = ($self->get($index)->findnodes('child::value'))[0]; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
return bless($val, 'POE::Filter::XML::RPC::Value'); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub add() |
|
92
|
|
|
|
|
|
|
{ |
|
93
|
|
|
|
|
|
|
my ($self, $val) = @_; |
|
94
|
|
|
|
|
|
|
return ($self->findnodes('child::params'))[0]->appendChild($val); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub delete() |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
|
|
|
|
|
|
my ($self, $index) = @_; |
|
100
|
|
|
|
|
|
|
return ($self->findnodes('child::params'))[0]->removeChild($self->get($index)); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub insert() |
|
104
|
|
|
|
|
|
|
{ |
|
105
|
|
|
|
|
|
|
my ($self, $val, $index) = @_; |
|
106
|
|
|
|
|
|
|
return ($self->findnodes('child::params'))[0]->insertBefore($val, $self->get($index)); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub get() |
|
110
|
|
|
|
|
|
|
{ |
|
111
|
|
|
|
|
|
|
my ($self, $index) = @_; |
|
112
|
|
|
|
|
|
|
return ($self->findnodes("child::params/child::param[position()=$index]"))[0]; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub wrap() |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
|
|
|
|
|
|
my ($self, $val) = @_; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $param = POE::Filter::XML::Node->new('param'); |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$param->appendChild($val); |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
return $param; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=pod |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 NAME |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
POE::Filter::XML::RPC::Request - An abstracted XMLRPC request |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
use 5.010; |
|
135
|
|
|
|
|
|
|
use POE::Filter::XML::RPC::Request; |
|
136
|
|
|
|
|
|
|
use POE::Filter::XML::RPC::Value; |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my $request = POE::Filter::XML::RPC::Request->new |
|
139
|
|
|
|
|
|
|
( |
|
140
|
|
|
|
|
|
|
'SomeRemoteMethod', |
|
141
|
|
|
|
|
|
|
[ |
|
142
|
|
|
|
|
|
|
POE::Filter::XML::RPC::Value->new('Some Argument') |
|
143
|
|
|
|
|
|
|
] |
|
144
|
|
|
|
|
|
|
); |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
say $request->method_name(); # SomeRemoteMethod |
|
147
|
|
|
|
|
|
|
say $request->get_parameter(1)->value(); # Some Argument |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
POE::Filter::XML::RPC::Request provides and abstracted XMLRPC request object |
|
152
|
|
|
|
|
|
|
to use when constructing requests to a remote server. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=over 4 |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item new() |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
new() accepts two arguments, one, the method name to be used, and two, an array |
|
161
|
|
|
|
|
|
|
reference of POE::Filter::XML::RPC::Value objects that are the positional |
|
162
|
|
|
|
|
|
|
arguments to the method in question. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item method_name() |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
method_name() returns the current method name of the request. Can also take an |
|
167
|
|
|
|
|
|
|
argument that will change the method name to the provided argument. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item parameters() |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
parameters() returns an array reference of all of the Values currently stored |
|
172
|
|
|
|
|
|
|
in the request in the order they were provided. This is a zero based array. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item get_parameter() |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
get_parameter() takes a one based index into the positional parameters of the |
|
177
|
|
|
|
|
|
|
request. Returns the Value object at that position. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item insert_parameter() |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
insert_parameter() takes two arguments, one, the Value object to be inserted and |
|
182
|
|
|
|
|
|
|
two, the one based index to which the Value should be associated. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item delete_parameter() |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
delete_parameter() takes a one based index into the positional parameters of the |
|
187
|
|
|
|
|
|
|
request. Returns the deleted Value. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item add_parameter() |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
add_parameter() takes a Value object as its sole argument and appends it to the |
|
192
|
|
|
|
|
|
|
end of the parameters of the request. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=back |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 Notes |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Request is actually a subclass of POE::Filter::XML::Node and so all of its |
|
199
|
|
|
|
|
|
|
methods, including XML::LibXML::Element's, are available for use. This could |
|
200
|
|
|
|
|
|
|
ultimately be useful to avoid marshalling all of the data out of the Node and |
|
201
|
|
|
|
|
|
|
instead apply an XPATH expression to target specifically what is desired deep |
|
202
|
|
|
|
|
|
|
within a nested structure. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
The reason the parameter methods are one based indexed is because of how XPATH |
|
205
|
|
|
|
|
|
|
works and what the spec calls out for when it comes to the position() |
|
206
|
|
|
|
|
|
|
predicate. |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 AUTHOR |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Copyright 2009 Nicholas Perez. |
|
211
|
|
|
|
|
|
|
Licensed and distributed under the GPL. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
1; |