2012-08-28 39 views
1

我剛剛開始研究拉力賽API。我想創建一個新的測試用例結果,但我不斷收到一個異常,不知道爲什麼。我認爲這會變成一件非常愚蠢的事情,但我無法弄清楚。新的拉力賽API,試圖添加測試用例結果

繼承人我的代碼:

public static void updateRally(){ 
    URL url 
    RallyService service = null 
    try{ 
     url = new URL("https://rally1.rallydev.com/slm/webservice/1.36/RallyService") 
     service = (new RallyServiceServiceLocator()).getRallyService(url) 
    } catch (MalformedURLException e){ 
     e.printStackTrace() 
     throw new Exception("RallyWebServiceClient.main problem in creating the url") 
    } catch (Exception e){ 
     e.printStackTrace() 
     throw new Exception("RallyWebServiceClient.main problem in creating the service") 
    } 

    if (service == null){ 
     println("Error: Service is null") 
     throw new Exception("RallyWebServiceClient.main service null...") 
    } 

    //Set authentication information on the service 
    Stub stub = (Stub)service 
    stub.setUsername("MyUsername") 
    stub.setPassword("MyPassword") 

    //Configure the service to maintain an HTTP session cookie 
    stub.setMaintainSession(true) 

    //Start calling methods on the service 
    User user = (User)service.getCurrentUser() 
    println(user.getDisplayName()) 

    TestCase testCase = new TestCase() 
    testCase.setName("TC7571") 

    TestCaseResult result = new TestCaseResult() 
    result.setTestCase(testCase) 
    result.setBuild("1.16.0-SNAPSHOT-6256") 
    result.setDuration(1.0) 
    result.setTester(user) 
    result.setVerdict("Pass") 

    CreateResult createResult = service.create(result) 
} 

我一直斥罵那裏有在主線程與EXCIT代碼1.它沒有得到過去它讀取用戶的用戶=(用戶)service.getCurrentUser線路異常()

我按照我在拉力賽網站上找到的指南。我懷疑問題是我正在使用的URL。我也嘗試了WSDL的URL而不是上面的內容,並得到相同的問題。

我感謝任何幫助,謝謝。

回答

2

我們建議新用戶嘗試我們的REST API,而不是SOAP的:

http://developer.rallydev.com/help/java-toolkit-rally-rest-api

然後,您應該能夠做到這樣的事情:

RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"), "[email protected]", "password"); 

JsonObject newTestCase = new JsonObject(); 
newTestCase.addProperty("Name", "Awesome Test"); 
CreateRequest createRequest = new CreateRequest("testcase", newTestCase); 
CreateResponse createResponse = restApi.create(createRequest); 

String newTestCaseRef = createResponse.getObject().get("_ref").getAsString(); 
相關問題