调用SharePoint Web服务的身份验证失败(JAX-WS客户端)

时间:2011-09-14 10:15:30

标签: web-services sharepoint-2010 jax-ws authenticator

我必须从Java客户端调用SharePoint 2010 Lists服务。

我使用NetBeans从WSDL生成JAX-WS类。

扩展java.net.Authenticator以管理对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()));
        }
    }

使用JAX-WS调用Web服务:

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);

我仍然收到错误:

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)

因为它无效我试过了:

  • 设置没有域的用户

  • 将域设置为系统属性:System.setProperty("http.auth.ntlm.domain", "XXXXXXXX");

  • 验证“老式方式”:

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

任何想法认证的问题是什么?

谢谢

0 个答案:

没有答案