xmlrpc.cgi 1.43 KB
Newer Older
1
#!/usr/bin/perl -T
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 12
use warnings;

13
use lib qw(. lib);
14 15 16

use Bugzilla;
use Bugzilla::Constants;
17
use Bugzilla::Error;
18
use Bugzilla::WebService::Constants;
19

20
BEGIN {
21 22 23
  if (!Bugzilla->feature('xmlrpc')) {
    ThrowUserError('feature_disabled', {feature => 'xmlrpc'});
  }
24
}
25
use Bugzilla::WebService::Server::XMLRPC;
26

27
Bugzilla->usage_mode(USAGE_MODE_XMLRPC);
28 29

# Fix the error code that SOAP::Lite uses for Perl errors.
30 31
local $SOAP::Constants::FAULT_SERVER;
$SOAP::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL;
32

33 34
# The line above is used, this one is ignored, but SOAP::Lite
# might start using this constant (the correct one) for XML-RPC someday.
35 36
local $XMLRPC::Constants::FAULT_SERVER;
$XMLRPC::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL;
37

38
local @INC = (bz_locations()->{extensionsdir}, @INC);
39
my $server = new Bugzilla::WebService::Server::XMLRPC;
40 41 42

# 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
43
# for setting SOAPAction, which isn't used by XML-RPC.
44
$server->on_action(sub { $server->handle_login(WS_DISPATCH, @_) })->handle();