Error de Java JBoss 401 en el servicio web de SharePoint 2010

Mi código se ejecuta con éxito cuando se prueba en el IDE de Eclipse.

Me estoy conectando a MS SharePoint 2010 a través de los servicios web utilizando el Copy.wsdl generado

Cuando despliegue mi código en el servidor JBoss (ejecutando Adobe LifeCycle), mi código recibe un error 401.

Error:

Caused by: org.jboss.ws.WSException: Invalid HTTP server response [401] - Unauthorized
at org.jboss.ws.core.soap.SOAPMessageUnMarshallerHTTP.read(SOAPMessageUnMarshallerHTTP.java:75)
at org.jboss.remoting.transport.http.HTTPClientInvoker.readResponse(HTTPClientInvoker.java:608)
at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:402)
at org.jboss.remoting.transport.http.HTTPClientInvoker.makeInvocation(HTTPClientInvoker.java:253)
... 156 more

Ahora, si utilizo el inicio de sesión incorrecto a través del IDE, aparece este error:

com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 401: Unauthorized

Actualizar:

Entonces, después de más investigación, resulta que es compatible con J2EE, y la falta de NTLM es la causa. He probado varias soluciones en vano hasta el momento.

Código:

protected void initialize(String username, String password) throws Exception {
    System.out.println("initialize()...");
    java.net.CookieManager cm = new java.net.CookieManager();
    java.net.CookieHandler.setDefault(cm);
    Authenticator.setDefault(new SharepointAuthenticator(username, password));
}

Autenticador

public class SharepointAuthenticator extends Authenticator {

private String username = "";
private String password = "";

public SharepointAuthenticator(String username, String password) {
    this.username = username;
    this.password = password;
    System.out.println("Initializing Authentication");
}

@Override
public PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication(username, password.toCharArray());
}
}

Obtener jabón

protected CopySoap getCopySoap(String username, String password, String wsdl, String endpoint) throws Exception {
    System.out.println("Creating a CopySoap instance...");
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    Copy service = new Copy(new URL(wsdl), new QName("http://schemas.microsoft.com/sharepoint/soap/", "Copy"));
    System.out.println("CopySoap 2");

    CopySoap copySoap = service.getCopySoap();

    System.out.println(endpoint + "\n" + wsdl);

    BindingProvider bp = (BindingProvider) copySoap;  
    bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
    bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
    return copySoap;
}

Llame para cargar el archivo:

    // make the call to upload
    port.copyIntoItems("null", destinationUrlCollection, metadata, byteArray, longHolder, resultHolder);

Respuestas a la pregunta(1)

Su respuesta a la pregunta