HTTP/1.1 403禁止访问 响应内容长度:729 结果:抛出了类型为'Microsoft.SharePoint.SoapServer.SoapServerException'的soap:ServerException。此页面的安全验证无效。在您的Web浏览器中点击“返回”,刷新页面,然后再次尝试操作。0x8102006d
我的问题是如何在同一会话中通过代理进行身份验证,并同时配置NTLM共享?请帮助我。
提前致谢。
AuthCache authCache = new BasicAuthCache();
HttpHost targetHost = new HttpHost(<sharepointserverhostname>);
NTLMSchemeFactory f = new NTLMSchemeFactory();
HttpContext ctx = new BasicHttpContext();
AuthScheme ns = f.create(ctx);
authCache.put(targetHost, ns);
HttpClientContext localContext = HttpClientContext.create();
localContext.setAuthCache(authCache);
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope(<proxyserverip>, 8080), new UsernamePasswordCredentials ("testdomain\phanigandeed", "Jul@2014"));
credsProvider.setCredentials(
AuthScope.ANY, new NTCredentials("phanigandeed", "Jul@2014", "", "testdomain"));
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
String listName = "PhaniList";
String description = "TestDescription";
String templateID = "101";
// for safety reasons, I had to remove the actual server details.
String endpointURL = <serviceurl>;
String result = "Failed";
String username = "phanigandeed";
String psWord = "Jul@2014";
String domainName = "vsnl";
String XML_DATA = new String("<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><AddList xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\"><listName>"
+ listName
+ "</listName><description>"
+ description
+ "</description><templateID>"
+ templateID
+ "</templateID></AddList></soap:Body></soap:Envelope>");
HttpPost httpPost = new HttpPost(endpointURL);
httpPost.setHeader(new BasicHeader("Content-Type",
"text/xml;charset=UTF-8"));
try {
StringEntity s = new StringEntity(XML_DATA, "UTF-8");
httpPost.setEntity(s);
System.out.println("executing request" + httpPost.getRequestLine());
HttpResponse response = httpclient.execute(httpPost, localContext);
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
if (entity != null) {
System.out.println("Response content length: "
+ entity.getContentLength());
result = EntityUtils.toString(entity);
System.out.println("Result: " + result);
entity.consumeContent();
}
System.out.println("result: " + result);
return;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Sharepoint Create Library failed :"
+ e.getMessage());
return;
}