2014-02-18 102 views
-1

我想通過Web服務訪問Sharepoint的列表。在Sharepoint Online上訪問Sharepoint Webservice的列表2013

我已經爲我的網絡服務嘗試了很多不同的Web引用URL。

的列表中找到在:

example.com/sites/dms/_layouts/15/start.aspx#/Lists/Documents/AllItems.aspx 

我使用的Web服務的URL現在是

https://example.com/sites/dms/_vti_bin/lists.asmx 

顯然example.com是不是真正的URL。

當我運行的代碼

service.GetList("Documents"); 

我得到的錯誤:

List does not exist.
The page you selected contains a list that does not exist. It may have been deleted by another user.
0x82000006

我完整的代碼(很多東西都只是爲了測試目的):

public void UpdateList() 
{ 
    MKLists.Lists service = GetService(); 

    string targetSite = "https://mywebpage.com/sites/dms"; 

    using (ClientContext ctx = ClaimClientContext.GetAuthenticatedContext(targetSite)) 
    { 
     if (ctx != null) 
     { 
      ctx.Load(ctx.Web); // Query for Web 
      ctx.ExecuteQuery(); // Execute 
      string test = (ctx.Web.Title); 
     } 
    } 

    CookieCollection authCookie = ClaimClientContext.GetAuthenticatedCookies(targetSite, 925, 525); 

    service.CookieContainer = new CookieContainer(); 
    service.CookieContainer.Add(authCookie); 

    XmlNode tester = service.GetList("Documents"); 
} 


    private MKLists.Lists GetService() 
    { 
     MKLists.Lists myService = new MKLists.Lists(); 
     myService.Credentials = System.Net.CredentialCache.DefaultCredentials; 
     return myService; 
    } 
+0

Stakoverflow已開發的Sharepoint網站,你應該問它在那裏你會得到正確的答案更多的在那裏。 –

回答

0

改變這line:

MKLists.Lists service = GetService(); 

MKLists.Lists service = new MKLists.Lists(); 

我希望這有助於。

編輯

根據在這裏回答您的評論

是更新@邁克爾 試着改變你的targetsite網址

string targetSite = "https://mywebpage.com/sites/dms/_vti_bin/Lists.asmx"; 

希望這一次它有助於

+0

對不起。 GetServices)是我編寫的一個輔助方法。我已編輯的問題,以顯示此 – michael

+0

@ michael檢查我的答案中的編輯部分 –

0

事實證明這是與子網站......這條線解決了它:

service.Url = "https://mywebpage.com/sites/dms/_vti_bin/lists.asmx";