Question

I have to call SharePoint 2010 Lists service from a Java client.

I used NetBeans to generate the JAX-WS classes from the WSDL.

And extended java.net.Authenticator to manage the authentication to SharePoint :

static final String user = "XXXXXXXX\\Administrateur"; // your account name
static final String pass = "mypassw"; // your password for the account

static class MyAuthenticator extends Authenticator {
        public PasswordAuthentication getPasswordAuthentication() {
            System.out.println("Feeding username and password for " + getRequestingScheme());
            return (new PasswordAuthentication(user, pass.toCharArray()));
        }
    }

Calling the web service with JAX-WS :

Authenticator.setDefault(new MyAuthenticator());

com.nm.Lists service = new com.nm.Lists();

com.nm.ListsSoap port = service.getListsSoap12();

String pageUrl = "http://xxxxxxx/testPushFile.txt";
String comment = "no comment";
String checkinType = "1";

boolean result = port.checkInFile(pageUrl, comment, checkinType);

I am still getting the error :

Exception in thread "main" javax.xml.ws.WebServiceException: java.io.IOException: Authentication failure
at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.readResponseCodeAndMessage(HttpClientTransport.java:201)

Because it isn't working I tried :

  • to set the user without the domain

  • to set the domain as a system property : System.setProperty("http.auth.ntlm.domain", "XXXXXXXX");

  • to authenticate "old-fashioned way" :

      
    ((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, user);
    ((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, pass);

Any ideas what's the problem with authentication ?

Thanks

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top