简体   繁体   English

身份验证失败,调用SharePoint Web Service(JAX-WS客户端)

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

I have to call SharePoint 2010 Lists service from a Java client. 我必须从Java客户端调用SharePoint 2010 Lists服务。

I used NetBeans to generate the JAX-WS classes from the WSDL. 我使用NetBeans从WSDL生成JAX-WS类。

And extended java.net.Authenticator to manage the authentication to SharePoint : 并扩展了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()));
        }
    }

Calling the web service with JAX-WS : 使用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);

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"); 将域设置为系统属性: 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 谢谢

I am coming back to give the solution. 我回来提供解决方案。 Here is what I have done to make the Web Service authentication work : 这是使Web服务身份验证工作完成的工作:

  • I enabled Basic Authentication in IIS Manager for my SharePoint Site, 我在SharePoint Manager的IIS管理器中启用了基本身份验证,
  • I used a user credentials that was registred in Windows Domain 我使用了Windows域中注册的用户凭据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM