xmlrpc.cgi 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env perl -wT
  2. # -*- Mode: perl; indent-tabs-mode: nil -*-
  3. #
  4. # The contents of this file are subject to the Mozilla Public
  5. # License Version 1.1 (the "License"); you may not use this file
  6. # except in compliance with the License. You may obtain a copy of
  7. # the License at http://www.mozilla.org/MPL/
  8. #
  9. # Software distributed under the License is distributed on an "AS
  10. # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  11. # implied. See the License for the specific language governing
  12. # rights and limitations under the License.
  13. #
  14. # The Original Code is the Bugzilla Bug Tracking System.
  15. #
  16. # Contributor(s): Marc Schumann <wurblzap@gmail.com>
  17. use strict;
  18. use lib qw(. lib);
  19. use Bugzilla;
  20. use Bugzilla::Constants;
  21. use Bugzilla::Error;
  22. use Bugzilla::Hook;
  23. use Bugzilla::WebService::Constants;
  24. # Use an eval here so that runtests.pl accepts this script even if SOAP-Lite
  25. # is not installed.
  26. eval 'use XMLRPC::Transport::HTTP;
  27. use Bugzilla::WebService;';
  28. $@ && ThrowCodeError('soap_not_installed');
  29. Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE);
  30. local $SOAP::Constants::FAULT_SERVER;
  31. $SOAP::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL;
  32. # The line above is used, this one is ignored, but SOAP::Lite
  33. # might start using this constant (the correct one) for XML-RPC someday.
  34. local $XMLRPC::Constants::FAULT_SERVER;
  35. $XMLRPC::Constants::FAULT_SERVER = ERROR_UNKNOWN_FATAL;
  36. my %hook_dispatch;
  37. Bugzilla::Hook::process('webservice', { dispatch => \%hook_dispatch });
  38. local @INC = (bz_locations()->{extensionsdir}, @INC);
  39. my $dispatch = {
  40. 'Bugzilla' => 'Bugzilla::WebService::Bugzilla',
  41. 'Bug' => 'Bugzilla::WebService::Bug',
  42. 'User' => 'Bugzilla::WebService::User',
  43. 'Product' => 'Bugzilla::WebService::Product',
  44. %hook_dispatch
  45. };
  46. # The on_action sub needs to be wrapped so that we can work out which
  47. # class to use; when the XMLRPC module calls it theres no indication
  48. # of which dispatch class will be handling it.
  49. # Note that using this to get code thats called before the actual routine
  50. # is a bit of a hack; its meant to be for modifying the SOAPAction
  51. # headers, which XMLRPC doesn't use; it relies on the XMLRPC modules
  52. # using SOAP::Lite internally....
  53. my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
  54. ->dispatch_with($dispatch)
  55. ->on_action(sub { Bugzilla::WebService::handle_login($dispatch, @_) } )
  56. ->handle;