我正在尝试对我的项目使用 NTLM 身份验证,但是当我在调试时收到此消息,我已经在这里停留了几天。
有什么问题?,这是我的代码:
String webserviceUrl = "http://ip/folder/page.xml"; // url of the web service.
String webserviceIP = "up"; // IP of the server.
String username = "user"; // Domain username
String password = "pass"; // Domain password
String deviceIP = "local"; // Device IP
String domainName = "domain"; // Domain name
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
httpclient.getCredentialsProvider().setCredentials(
new AuthScope(webserviceIP, -1),
new NTCredentials(username, password, deviceIP, domainName));
HttpGet httpGet = new HttpGet(webserviceUrl);
httpGet.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
HttpResponse response = httpclient.execute(httpGet); //ERROR HAPPENS HERE
String responseXML = EntityUtils.toString(response.getEntity());
注意:我在项目中添加了一个外部 jar 以使用 NTML 功能。我向清单授予了互联网许可。
////////////////编辑 我有这个问题,我试图从主要活动中执行我的代码,关于异步任务:如何修复android.os.NetworkOnMainThreadException?
但现在我找不到源代码