Authentication failure calling SharePoint Web Service (JAX-WS client)

六月ゝ 毕业季﹏ 提交于 2019-12-08 02:03:37

问题


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


回答1:


I am coming back to give the solution. Here is what I have done to make the Web Service authentication work :

  • I enabled Basic Authentication in IIS Manager for my SharePoint Site,
  • I used a user credentials that was registred in Windows Domain


来源:https://stackoverflow.com/questions/7414622/authentication-failure-calling-sharepoint-web-service-jax-ws-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!