0

尝试使用 url 时,我得到 URI 不能为空

下面是我的代码,

HttpService.setSslSecurityProtocol(SSLSecurityProtocol.SSLv3);
 //Tried the below one also
 //HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);

      ServiceArgs loginArgs  = new ServiceArgs();
      loginArgs.setUsername("username");
      loginArgs.setPassword("password");
      loginArgs.setHost("my splunk url"); //for eg http://splunkdet.mysite.com:8000/login
      loginArgs.setPort(8000);

      Service service = Service.connect(loginArgs);

      for (Application app: service.getApplications().values()) {
       System.out.println(app.getName());
      }

获取异常“ URI 不能为空Service service = Service.connect(loginArgs);

我的代码有什么问题?

4

1 回答 1

0

由于您使用的是 http 而不是 https,因此您不需要使用 HttpService.setSslSecurityProtocol。

而是将方案添加到您的 ServiceArgs 示例中: loginArgs.setScheme("http");

并且不要在传递给 setHost 的 URL 中包含 http:// 或 https://。

于 2020-11-05T17:03:38.813 回答