身份验证失败,调用SharePoint Web Service(JAX-WS客户端) [英] Authentication failure calling SharePoint Web Service (JAX-WS client)

查看:115
本文介绍了身份验证失败,调用SharePoint Web Service(JAX-WS客户端)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

并扩展了java.net.Authenticator以管理对SharePoint的身份验证:

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

使用JAX-WS调用Web服务:

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

我仍然收到错误消息:

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

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

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

验证老式方式":

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

任何想法,身份验证有什么问题?

Any ideas what's the problem with authentication ?

谢谢

推荐答案

我回来提供解决方案.这是使Web服务身份验证工作完成的工作:

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

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

这篇关于身份验证失败,调用SharePoint Web Service(JAX-WS客户端)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆