line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Model::XMLRPC; |
2
|
2
|
|
|
2
|
|
51524
|
use base qw/Catalyst::Model/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1162
|
|
3
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
70
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
67
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
154
|
|
7
|
2
|
|
|
2
|
|
3014
|
use NEXT; |
|
2
|
|
|
|
|
10875
|
|
|
2
|
|
|
|
|
66
|
|
8
|
2
|
|
|
2
|
|
2851
|
use RPC::XML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use RPC::XML::Client; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
12
|
|
|
|
|
|
|
our $AUTOLOAD; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
|
|
|
|
|
|
my ($class, $c, $config) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $self = $class->NEXT::new($c, $config); |
19
|
|
|
|
|
|
|
$self->config($config); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _client { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
my %config = %{ $self->config }; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $location = $config{location}; |
30
|
|
|
|
|
|
|
croak "Must provide an location" unless $location; |
31
|
|
|
|
|
|
|
delete $config{location}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
unless (exists $config{error_handler}) { |
34
|
|
|
|
|
|
|
$config{error_handler} = sub { croak $_[0] }; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
unless (exists $config{fault_handler}) { |
37
|
|
|
|
|
|
|
$config{fault_handler} = sub { croak $_[0] }; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $client = RPC::XML::Client->new($location, %config); |
41
|
|
|
|
|
|
|
croak "Can't create RPC::XML::Client object" |
42
|
|
|
|
|
|
|
unless UNIVERSAL::isa($client, 'RPC::XML::Client'); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return $client; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub AUTOLOAD { |
49
|
|
|
|
|
|
|
my ($self, @args) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return if $AUTOLOAD =~ /::DESTROY$/; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
(my $op = $AUTOLOAD) =~ s/^.*:://; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $client = $self->_client; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $msg = $client->$op(@args); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return $msg; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Catalyst::Model::XMLRPC - XMLRPC model class for Catalyst |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SYNOPSIS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Model |
74
|
|
|
|
|
|
|
__PACKAGE__->config( |
75
|
|
|
|
|
|
|
location => 'http://webservice.example.com:9000', |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Controller |
79
|
|
|
|
|
|
|
sub default : Private { |
80
|
|
|
|
|
|
|
my ($self, $c) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $res; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
eval { |
85
|
|
|
|
|
|
|
$res = $c->model('RemoteService')->send_request('system.listMethods'); |
86
|
|
|
|
|
|
|
$c->stash->{value} = $res->value; |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
if ($@) { |
89
|
|
|
|
|
|
|
# Something went wrong... |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
... |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DESCRIPTION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This model class uses L<RPC::XML::Client> to invoke remote procedure calls |
99
|
|
|
|
|
|
|
using XML-RPC. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 CONFIGURATION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
You can pass the same configuration fields as when you call |
104
|
|
|
|
|
|
|
L<RPC::XML::Client>, the only special thing is that the URI is provided via |
105
|
|
|
|
|
|
|
the B<location> field. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 METHODS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 General |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Take a look at L<RPC::XML::Client> to see the method you can call. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 new |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Called from Catalyst. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 NOTES |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
By default, there is an B<error_handler> and a B<fault_handler> provided |
120
|
|
|
|
|
|
|
for the L<RPC::XML::Client> object that call L<Carp::croak>. |
121
|
|
|
|
|
|
|
You can override it if you want via the config call. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 Must provide an location |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
You'll get this error, if you haven't provided a location. See Config. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 Can't create RPC::XML::Client object |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Something went wrong while trying to create an L<RPC::XML::Client> object. See |
132
|
|
|
|
|
|
|
documentation of this module for further references. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SEE ALSO |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=over 1 |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * L<RPC::XML::Client> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * L<RPC::XML> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * L<Catalyst::Model> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=back |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=over 1 |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * Daniel Westermann-Clark's module, L<Catalyst::Model::LDAP>, it was my reference. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * Lee Aylward, for reporting the issue regarding v.0.03. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=back |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 AUTHOR |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Florian Merges, E<lt>fmerges@cpan.orgE<gt> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 LICENSE |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
163
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |