甚至可能吗?文档没有说清楚。我尝试了各种不同的机制来使身份验证正常工作,但我不断收到“401:未经授权”错误。这是我所在的位置:
stub = new EngineStub();
HttpClient client = new HttpClient();
client.getParams().setAuthenticationPreemptive(true);
stub._getServiceClient().getServiceContext().getConfigurationContext().setProperty(HTTPConstants.CACHED_HTTP_CLIENT, client);
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
List<String> authpref = new ArrayList<String>();
authpref.add(AuthPolicy.BASIC);
auth.setAuthSchemes(authpref);
auth.setUsername(username);
auth.setPassword(password);
auth.setPreemptiveAuthentication(true);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);