HttpTransportProperties

HttpTransportProperties

刚刚使用Apache Axis 2从WSDL中生成了Java代码。该服务受基本身份验证保护。当我尝试创建身份验证对象以设置用户名和密码时,在库中找不到类(HttpTransportProperties.Authenticator)。

如何为Apache Axis2生成的客户端代码设置基本身份验证?

这是设置基本身份验证参数的旧方法:

HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
basicAuth.setUsername("username");
basicAuth.setPassword("password");
basicAuth.setPreemptiveAuthentication(true);

final Options clientOptions = stub._getServiceClient().getOptions();
clientOptions.setProperty(HTTPConstants.AUTHENTICATE, basicAuth);
stub._getServiceClient().setOptions(clientOptions);

最佳答案

我有同样的问题!

解决方案:使用HttpTransportPropertiesImpl代替HttpTransportProperties

09-27 17:22