intento acceder a una lista de SharePoint a través de JAX-WS como se describe hereJAX-WS Sharepoint 401 NTLM no autorizado
Sin embargo, cuando se ejecuta el código de abajo me sale:
java.lang.Exception: Exception. See stacktrace.com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 401: Unauthorized
Sharepoint requiere autenticación NTLM. ¿Cuál puede ser el problema? ¡Muchas gracias!
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;
}
¿Es solo configuraciones para toda la aplicación? ¿Qué ocurre si necesito autenticar solo una solicitud en particular con esas credenciales? – glaz666
Puede decir qué URL está solicitando las credenciales con getRequestingURL() dentro de su clase personalizada de Autenticador. Por lo tanto, puede devolver las credenciales en consecuencia. – jmend
@MarcelLevy - ¿Dónde encaja el código que proporcionó con el código en la pregunta del OP? El enlace que proporcionó está ahora muerto ... – Joe