]> git.donarmstrong.com Git - debbugs.git/blob - cgi/soap.cgi
8c1ec3c5c3466d45d6168f22ec299311fc2326da
[debbugs.git] / cgi / soap.cgi
1 #!/usr/bin/perl -T
2
3 use warnings;
4 use strict;
5
6 # if we're running out of git, we want to use the git base directory as the
7 # first INC directory. If you're not running out of git, don't do that.
8 use File::Basename qw(dirname);
9 use Cwd qw(abs_path);
10 our $debbugs_dir;
11 BEGIN {
12     $debbugs_dir =
13         abs_path(dirname(abs_path(__FILE__)) . '/../');
14     # clear the taint; we'll assume that the absolute path to __FILE__ is the
15     # right path if there's a .git directory there
16     ($debbugs_dir) = $debbugs_dir =~ /([[:print:]]+)/;
17     if (defined $debbugs_dir and
18         -d $debbugs_dir . '/.git/') {
19     } else {
20         undef $debbugs_dir;
21     }
22     # if the first directory in @INC is not an absolute directory, assume that
23     # someone has overridden us via -I.
24     if ($INC[0] !~ /^\//) {
25     }
26 }
27 use if defined $debbugs_dir, lib => $debbugs_dir;
28
29 #use SOAP::Transport::HTTP;
30
31 use Debbugs::SOAP::Server;
32
33 # Work around stupid soap bug on line 411
34 if (not exists $ENV{EXPECT}) {
35      $ENV{EXPECT} = '';
36 }
37
38 my $soap = Debbugs::SOAP::Server
39 #my $soap = SOAP::Transport::HTTP::CGI
40     -> dispatch_to('Debbugs::SOAP');
41 #$soap->serializer()->soapversion(1.2);
42 # soapy is stupid, and is using the 1999 schema; override it.
43 *SOAP::XMLSchema1999::Serializer::as_base64Binary = \&SOAP::XMLSchema2001::Serializer::as_base64Binary;
44 *SOAP::Serializer::as_anyURI       = \&SOAP::XMLSchema2001::Serializer::as_string;
45 # do this twice to avoid the warning if the serializer doesn't get
46 # used
47 *SOAP::XMLSchema1999::Serializer::as_base64Binary = \&SOAP::XMLSchema2001::Serializer::as_base64Binary;
48 *SOAP::Serializer::as_anyURI       = \&SOAP::XMLSchema2001::Serializer::as_string;
49 # to work around the serializer improperly using date/time stuff
50 # (Nothing in Debbugs should be looked at as if it were date/time) we
51 # kill off all of the date/time related bits in the serializer.
52 my $typelookup = $soap->serializer()->{_typelookup};
53 for my $key (keys %{$typelookup}) {
54     if (defined $key and
55         $key =~ /Month|Day|Year|date|time|duration/i
56        ) {
57         # set the sub to always return 0
58         $typelookup->{$key}[1] = sub { 0 };
59     }
60 }
61
62 our $warnings = '';
63 eval {
64     # Ignore stupid warning because elements (hashes) can't start with
65     # numbers
66     local $SIG{__WARN__} = sub {$warnings .= $_[0] unless $_[0] =~ /Cannot encode unnamed element/};
67     $soap->handle;
68 };
69 die $@ if $@;
70 warn $warnings if length $warnings;