1 package FS::SelfService::XMLRPC;
5 FS::SelfService::XMLRPC - Freeside XMLRPC accessible self-service API
11 Use this API to implement your own client "self-service" module vi XMLRPC.
13 Each routine described in L<FS::SelfService> is available vi XMLRPC as the
14 method FS.SelfService.XMLRPC.B<method>. All values are passed to the
15 selfservice-server in a struct of strings. The return values are in a
16 struct as strings, arrays, or structs as appropriate for the values
17 described in L<FS::SelfService>.
23 L<freeside-selfservice-clientd>, L<freeside-selfservice-server>,L<FS::SelfService>
28 use vars qw($DEBUG $AUTOLOAD);
29 use XMLRPC::Lite; # for XMLRPC::Data
33 $FS::SelfService::DEBUG = $DEBUG;
35 #false laziness w/FS::ClientAPI_XMLRPC.pm
36 our %typefix_skin_info = (
38 'title_left_image' => 'base64',
39 'title_right_image' => 'base64',
40 'menu_top_image' => 'base64',
41 'menu_body_image' => 'base64',
42 'menu_bottom_image' => 'base64',
45 'invoice_pdf' => { 'invoice_pdf' => 'base64', },
46 'legacy_invoice_pdf' => { 'invoice_pdf' => 'base64', },
47 'skin_info' => \%typefix_skin_info,
48 'payment_only_skin_info' => \%typefix_skin_info,
49 'login_info' => \%typefix_skin_info,
50 'logout' => \%typefix_skin_info,
51 'access_info' => \%typefix_skin_info,
52 'reset_passwd' => \%typefix_skin_info,
53 'check_reset_passwd' => \%typefix_skin_info,
54 'process_reset_passwd' => \%typefix_skin_info,
55 'invoice_logo' => { 'logo' => 'base64', },
56 'login_banner_image' => { 'image' => 'base64', },
57 'quotation_print' => { 'document' => 'base64' },
62 $call =~ s/^FS::SelfService::XMLRPC:://;
64 if (exists($FS::SelfService::autoload{$call})) {
66 shift; #discard package name;
68 $call = "FS::SelfService::$call";
72 my $return = &{$call}(@_);
74 if ( exists($typefix{$call}) ) {
75 my $typefix = $typefix{$call};
76 foreach my $field ( grep exists($return->{$_}), keys %$typefix ) {
77 my $type = $typefix->{$field};
78 $return->{$field} = XMLRPC::Data->value($return->{$field})
86 die "No such procedure: $call";
90 package SOAP::Transport::HTTP::Daemon; # yuck
92 use POSIX qw(:sys_wait_h);
94 no warnings 'redefine';
97 my $self = shift->new;
99 local $SIG{CHLD} = 'IGNORE';
102 while (my $c = $self->accept) {
106 $kid = waitpid(-1, WNOHANG);
107 warn "found kid $kid";
113 if ( not defined $pid ) {
114 warn "fork() failed: $!";
117 while (my $r = $c->get_request) {
119 $self->SUPER::handle;
120 $c->send_response($self->response);
122 # replaced ->close, thanks to Sean Meisner <Sean.Meisner@VerizonWireless.com>
123 # shutdown() doesn't work on AIX. close() is used in this case. Thanks to Jos Clijmans <jos.clijmans@recyfin.be>
124 UNIVERSAL::isa($c, 'shutdown') ? $c->shutdown(2) : $c->close();