1

我刚刚开始研究集会 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。它没有超过读取 User user = (User)service.getCurrentUser() 的行

我按照在 Rally 网站上找到的指南进行操作。我怀疑问题出在我使用的 URL 上。我还尝试了 WSDL 的 URL 而不是上面的内容,并遇到了同样的问题。

我感谢任何帮助,谢谢。

4

1 回答 1

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();
于 2012-08-28T12:44:07.403 回答