2012-12-13 94 views
0

我想在.net中使用PSI Web服務讀取項目列表。我不知道什麼是錯誤的,在請求web方法時,我總是得到「未處理的通信故障發生」異常。來自Microsoft Project Project Server 2010的ReadProjectList

有人可以幫我解決它PLZ。

我使用的Web引用,並用下面的代碼使用VS 2010

  1. 增加,(實際用戶名和密碼發送給) 網絡參考網址:服務器/ ProjectServerName/_vti_bin/PSI/project.asmx ?wsdl

    svcProject.Project prj2 = new svcProject.Project(); prj2.Credentials = new NetworkCredential(「testuser」,「testpassword」); svcProject.ProjectDataSet lst2 = prj2.ReadProjectList();

  2. 我試圖與WCF參考也與下面碼

    ProjectSoapClient.ProjectSoapClient PRJ =新ProjectSoapClient.ProjectSoapClient(); prj.ClientCredentials.Windows.ClientCredential = new NetworkCredential(「testuser」,「testpassword」,「SDP」); prj.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation; ProjectDataSet lst = prj.ReadProjectList();

我總是得到「未處理的通訊故障發生」的錯誤,

一些曾經有助於使在Project Server 2010中的更改用戶權限或認證改變

在感謝提前

回答

0

您是否在嘗試捕捉soapexception?

catch (SoapException ex) 
    { 

     PSLib.PSClientError error = new PSLib.PSClientError(ex); 
     PSLib.PSErrorInfo[] errors = error.GetAllErrors(); 
     PSLib.PSErrorInfo thisError; 
     for (int i = 0; i < errors.Length; i++) 
     { 
      thisError = errors[i]; 
     } 
     string StrException = ex.ToString() + " \r\nInner Exception: " + ex.InnerException.ToString(); 

    } 

你有沒有試過認證login.asmx服務,而不是做非人格化

//Creating a new service client object 
    ProjectDerived projectSvc = new ProjectDerived(); 
    projectSvc.Url = projectServerUrl + "Project.asmx"; 
    projectSvc.Credentials = CredentialCache.DefaultCredentials; 
    projectSvc.CookieContainer = GetLogonCookie(); 
    projectSvc.EnforceWindowsAuth = isWindowsUser; 


// Get a CookieContainer property from the derived LoginWindows object. 
private static CookieContainer GetLogonCookie() 
{ 
    // Create an instance of the loginWindows object. 
    LoginWindowsDerived loginWindows = new LoginWindowsDerived(); 
    loginWindows.EnforceWindowsAuth = true; 
    loginWindows.Url = projectServerUrl + "LoginWindows.asmx"; 
    loginWindows.Credentials = CredentialCache.DefaultCredentials; 

    loginWindows.CookieContainer = new CookieContainer(); 


    if (!loginWindows.Login()) 
    { 
     // Login failed; throw an exception. 
     throw new UnauthorizedAccessException("Login failed."); 
    } 
    return loginWindows.CookieContainer; 
}