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

发布于 2024-12-04 09:38:11 字数 1746 浏览 4 评论 0原文

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

我使用 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)

因为它不起作用,我尝试:

  • 设置没有域的用户< /p>

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

  • 以“老式方式”进行身份验证:

    <前> <代码> ((BindingProvider) 端口).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, 用户);
    ((BindingProvider) 端口).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, pass);

您知道身份验证有什么问题吗?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妞丶爷亲个 2024-12-11 09:38:11

我回来给出解决方案。以下是我为使 Web 服务身份验证正常工作所做的操作:

  • 我在 IIS 管理器中为我的 SharePoint 站点启用了基本身份验证,
  • 我使用了在 Windows 域中注册的用户凭据

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文