2012-02-10 3 views
0
'비 레일의 REST API에 대해 ActiveResource을 사용하고

와 비 레일 REST API를 소비 ... 심지어 "나머지"부분이 의심 스럽다 사실이지만 시도 :는 ActiveResource

Although RESTful applications are ideally stateless, the ALM platform requires sessions to manage locking, client life time, and perform other basic tasks. Session management is performed using a cookie named QCSession.

을 어쨌든, 내가 필요 하나의 GET을 "authentication-point/authenticate"로 발행하여 사용자를 인증하고 쿠키를 다시 가져옵니다. 어떻게하는지 잘 모르겠습니다. 여기에 내가 가진 것은 있지만 404 오류가 발생합니다 :

class AlmActiveResource < ActiveResource::Base 
    attr_accessor :lwsso_cookie, :qcsession_cookie 

    self.site  = "http://alm_url/qcbin/" 
    self.user  = "name" 
    self.password = "pw" 

    def self.authentication 
    @auth_point = "authentication-point/authenticate" 
    self.prefix(@auth_point) 
    meow = self.get(:authenticate) 
    Rails.logger.debug("Meow: #{meow.inspect}") 

    end 
end 

답변

2

나는 똑같은 문제가있었습니다. 마침내 ALM과 대화하기 위해 컨트롤러에 모든 것을 넣어야했습니다. 최고는 아니지만 효과가 있습니다. 여기에 ReleaseCycles 컨트롤러에서 색인 조치는 다음과 같습니다

def index 
    conn=getAuthenticatedCurl 
    conn.url="#{$HPQC_REST_URL}/release-cycles" 
    conn.perform 
    results=conn.response_code 
    hash=Hash.from_xml(conn.body_str) 
    respond_to do |format| 
     format.html { render :xml => hash } 
     format.xml { render :xml => hash } 
     format.json { render :json => hash } 
    end 
    conn.url=$HPQC_LOGOUT_URL 
    conn.perform 
    conn.close 
    return results 
end 

내가와 ApplicationController에서 GET "getAuthenticatedCurl"를 만들었습니다. 모양은 다음과 같습니다.

매우 좋지 않지만 작동이 빠르고 빠릅니다. 내 다음 단계는 ActiveResource와 동일한 작업을 수행하는 것입니다. 희망과 도움이 행운을 빕니다!

+0

미친 소품! 고맙습니다. – ScottJShea

관련 문제