尝试检索Sharepoint WSDL失败,出现“服务器重定向次数过多”的错误。

4
我正在尝试通过Java代码连接到Sharepoint服务器。我的代码可以在一些Sharepoint服务器上正常工作,但在尝试连接到我提供的Comcast帐户时失败了。类ListsSoapLists是使用wsimport从Sharepoint WSDL生成的。
我读到这可能是由于没有使用doman\username作为Sharepoint用户名引起的。我尝试在用户名参数前面添加不同的域,例如mycompany.comcastbiz.net\\me@mycompany.comcastbiz.net,但我尝试的所有域名都收到了401错误。
BasicHTTPAuthenticator auth = new BasicHTTPAuthenticator("me@mycompany.comcastbiz.net", password);
Authenticator.setDefault(auth);

Lists listsService = new com.microsoft.schemas.sharepoint.soap.Lists();
listsSoap = listsService.getListsSoap12();

import java.net.Authenticator;

import java.net.PasswordAuthentication;

class BasicHTTPAuthenticator extends Authenticator
{

    private String userName;
    private String password;

    public BasicHTTPAuthenticator(String userName, String password)
    {
        this.userName = userName;
        this.password = password;
    }

    @Override
    protected PasswordAuthentication getPasswordAuthentication()
    {
        return new PasswordAuthentication(userName, password.toCharArray());
    }

    public String getUserName()
    {
        return userName;
    }

    public void setUserName(String userName)
    {
        this.userName = userName;
    }

    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }
}

public class Lists extends Service
{

    private final static URL LISTS_WSDL_LOCATION;
    private final static Logger logger = Logger.getLogger(com.microsoft.schemas.sharepoint.soap.Lists.class.getName());

    static {
        URL url = null;
        try {
            URL baseUrl;
            baseUrl = com.microsoft.schemas.sharepoint.soap.Lists.class.getResource(".");
            url = new URL(baseUrl, SharepointService.getServerUrl()+"/_vti_bin/Lists.asmx?WSDL");
        } catch (MalformedURLException e) {
            logger.warning("Failed to create URL for the wsdl Location: " + SharepointService.getServerUrl()+"/_vti_bin/Lists.asmx?WSDL");
            logger.warning(e.getMessage());
        }

        LISTS_WSDL_LOCATION = url;
    }

    public Lists() {
        super(LISTS_WSDL_LOCATION, new QName("http://schemas.microsoft.com/sharepoint/soap/", "Lists"));
    }

    ...

}

它失败了,错误信息如下:

javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://www.po1.comcast.net/sites/mycompany//_vti_bin/Lists.asmx?WSDL.

Server redirected too many times (20).
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:162)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:144)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:265)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:228)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:176)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)

1
mycompany.comcastbiz.net\me@mycompany.comcastbiz.net 绝对不是正确的格式。Windows 有两种认证凭据形式:1)UPN,看起来像电子邮件地址 user@something,但实际上不必与电子邮件地址或 Active Directory FQDN 域相关联(通常是这样,但不必须)。或者 Domain\samAccountName - samAccountName 是某个凭据用户名,它绝对没有 @,不一定与 VPN 相关,等等。在 LDAP 下是 samAccountName 属性。 - MJB
2个回答

0

我尝试过在用户名之前不加域名,没有出现这个错误,也许它不理解域名,请使用soapUI测试连接,如果可以连接,那么只是连接webservice的方式不好,因此有另一种方法,即使用REST API来访问SharePoint...


0

你的正确用户名应为"mycompany.comcastbiz.net\\me"。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接