xmlrpc.cgi 1.43 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 5.10.1;
10
use strict;
11
use lib qw(. lib);
12 13 14

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

24
Bugzilla->usage_mode(USAGE_MODE_XMLRPC);
25 26

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

34
local @INC = (bz_locations()->{extensionsdir}, @INC);
35 36 37 38 39 40
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();