You need to sign in or sign up before continuing.
xmlrpc.cgi 1.42 KB
Newer Older
1
#!/usr/bin/perl -wT
2 3 4
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
#
6 7
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
8 9

use strict;
10
use lib qw(. lib);
11 12 13

use Bugzilla;
use Bugzilla::Constants;
14
use Bugzilla::Error;
15
use Bugzilla::WebService::Constants;
16 17
BEGIN {
    if (!Bugzilla->feature('xmlrpc')) {
18
        ThrowUserError('feature_disabled', { feature => 'xmlrpc' });
19
    }
20
}
21
use Bugzilla::WebService::Server::XMLRPC;
22

23
Bugzilla->usage_mode(USAGE_MODE_XMLRPC);
24 25

# Fix the error code that SOAP::Lite uses for Perl errors.
26 27
local $SOAP::Constants::FAULT_SERVER;
$SOAP::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL;
28 29
# The line above is used, this one is ignored, but SOAP::Lite
# might start using this constant (the correct one) for XML-RPC someday.
30 31
local $XMLRPC::Constants::FAULT_SERVER;
$XMLRPC::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL;
32

33
local @INC = (bz_locations()->{extensionsdir}, @INC);
34 35 36 37 38 39
my $server = new Bugzilla::WebService::Server::XMLRPC;
# We use a sub for on_action because that gets us the info about what 
# class is being called. Note that this is a hack--this is technically 
# for setting SOAPAction, which isn't used by XML-RPC.
$server->on_action(sub { $server->handle_login(WS_DISPATCH, @_) })
       ->handle();