我试着描述hereJAX-WS的Sharepoint 401未授权NTLM
通过JAX-WS访问SharePoint列表但是,当运行代码时下面我得到:
java.lang.Exception: Exception. See stacktrace.com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 401: Unauthorized
的Sharepoint需要NTLM身份验证。可能是什么问题?非常感谢!
public static ListsSoap sharePointListsAuth(String userName, String password) throws Exception {
ListsSoap port = null;
if (userName != null && password != null) {
try {
Lists service = new Lists();
port = service.getListsSoap();
System.out.println("Web Service Auth Username: " + userName);
((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, userName);
((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
} catch (Exception e) {
throw new Exception("Error: " + e.toString());
}
} else {
throw new Exception("Couldn't authenticate: Invalid connection details given.");
}
return port;
}
难道只有整个应用程序的设置?如果我需要使用该凭据对特定请求进行身份验证,该怎么办? – glaz666 2011-07-07 12:27:35