2011-06-14 56 views
4

我試圖通過Java代碼連接到Sharepoint服務器。我的代碼在某些Sharepoint服務器上正常工作,但在嘗試連接到我的Comcast提供的帳戶時失敗。類ListsSoapLists是使用wsimport從Sharepoint WSDL生成的。試圖檢索Sharepoint WSDL失敗,並且「服務器重定向了太多次」

我讀過這可能是由於不使用doman \ username作爲Sharepoint用戶名。我嘗試將不同的域添加到用戶名參數中,例如mycompany.comcastbiz.net\\[email protected],但我收到了我嘗試過的所有域名的401錯誤。

BasicHTTPAuthenticator auth = new BasicHTTPAuthenticator("[email protected]", 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 \ [email protected]絕對不是正確的形式。 Windows有兩種形式的身份驗證器憑證:1)UPN,它看起來像電子郵件地址user @ something,但實際上不必與電子郵件地址或Active Directory FQDN域關聯(通常是,但不必關聯) 。或Domain \ samAccountName - samAccountName是一些憑證用戶名,它絕對沒有@,與vpn無關,等等。在LDAP下的samAccountName屬性中 – MJB 2011-06-14 19:36:03

回答

0

爲您正確的用戶名是 「mycompany.comcastbiz.net \\我」。

0

我嘗試沒有域之前,用戶,我沒有這個錯誤,也許它不明白的領域,嘗試與soapUI來測試連環,如果沒關係,它只是與webservice conncting的方式是不好,所以它是另一種方式,REST API訪問共享點...

相關問題