以编程方式进行SoapUI Web服务身份验证

时间:2014-09-12 16:05:56

标签: web-services junit soapui

我正在使用SoapUi API编写SOAP Web服务测试。我正在使用SoapUITestCaseRunner。
我的代码看起来像

public class MyRunner extends SoapUITestCaseRunner{
  public void runTest(){
     setProjectFile("pro_file_path");
     setEndpoint("endpoint");
     setUsername("username");
     setPassword("password");
     setTestSuite("testSuiteName");
     setTestCase("TestCaseName");
     run();
 }

}
public class MyTestClass(){
    @Test
    public void test(){
        new MyRunner().runTest();
    }
}
  

但用户名和密码作为属性传递(我可以在junit失败日志中看到它们)。   
服务是说401未经授权?我错过了什么吗?是否需要做任何事情来传递用户名和密码?

1 个答案:

答案 0 :(得分:0)

我得到了答案。问题在于我用来创建project.xml文件的SoapUI版本。如果我们使用低于5.0.0的版本创建项目并在编写junit时使用5.0.0它将无法工作。
实际上,似乎SoapUI啊在5.0.0中对认证部分进行了更改,其中有更多的选项,如NTML。
因此我们必须在project.xml中配置身份验证类型,并发送在project.xml中预先配置的用户名和密码,或者通过junit手动发送。