Rally API新手,尝试添加测试用例结果

时间:2012-08-28 10:27:50

标签: java soap rally

我刚刚开始研究拉力赛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)
}

我一直在主线程中通过兴奋码1告诉theres一个异常。它没有超过读取用户user =(User)service.getCurrentUser()

的行

我正在关注我在拉力赛网站上找到的指南。我怀疑问题是我正在使用的URL。我也尝试过WSDL的URL,而不是上面的内容,并得到同样的问题。

感谢任何帮助,谢谢。

1 个答案:

答案 0 :(得分:2)

我们建议新用户尝试使用REST api而不是SOAP:

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

然后你应该能够做到这样的事情:

RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"), "user@company.com", "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();