2012-08-28 146 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(); 
相关问题