2011-03-09 4 views
1

나는 버그질라의 웹 서비스의 bug.get 기능에 액세스 할 수 JSONRPC 사용하고 있지만, 반환 : bugzilla webservice는 bug.get에 인증이 필요합니까?

Error: 403
Forbidden Content-Type: text/xml
No data.

나는 다음 프록시 역할과에 POST 요청을 보내는 내 서버에 아약스 전화를 걸 bugzilla webservice (별도의 도메인에 있음).

var obj={ 
    'method':'Bug.get', 
    'params':{ 
     'id':bug_list 
    }, 
    'id':bug_list 
}; 
var message=$.toJSON(obj); 

$.ajax({ 
    "contentType":"application/json", 
    "data": message, 
    "dataType": "json", 
    "url": "bug_reply.cgi", 
    "type": "post", 
    error: function(d, ts, er){ 
     console.log("OH WOE! D: D: D: D: D: D: D: D: D:"+d+' '+ts+' '+er); 
    }, 
    success: function(d, ts){ 
     console.log(d); 
    } 
}); 

CGI :

#! /usr/bin/perl 

use strict; 

use lib qw(.); 
use CGI qw(:standard Vars); 
use vars qw($cgi $template $vars); 

use Bug; 
use Bugzilla; 
use Bugzilla::Search; 
use JSON::XS; 
use LWP::UserAgent; 
use CGI qw(:standard); 


# Include the Bugzilla CGI and general utility library. 
require "CGI.pl"; 

my $ua = LWP::UserAgent->new; 


my %form = Vars(); 
if($ENV{REQUEST_METHOD} eq "POST") 
{ 
    my $URL='http://bugs1.eng.proofpoint.com/bugzilla-3.6.4/jsonrpc.cgi'; 

    my $q = new CGI; 
    #my $query = 
    my $data=$form{'POSTDATA'}; 

    my $req=HTTP::Request->new(POST=>$URL); 
    $req->content_type('application/x-www-form-urlencoded'); 
    $req->content($data); 

    my $ua = LWP::UserAgent->new; 
    my $res = $ua->request($req); 

    if ($res->is_success) { 
     printf "Content-Type: %s\n\n", $res->header('Content-Type'); 
     print $res->content; 
    } 
    else { 
     printf "Content-Type: text/plain\n\n"; 
     print "Error: " . $res->status_line . "\n"; 
    } 

    print $cgi->header(-type => 'text/xml'); 
    print $res->decoded_content; 
} 

답변

0

난 그냥 대신 컬를 사용하고 일했다.

관련 문제