2012-10-08 68 views
1

我想尋求幫助。 我需要編寫遠程連接到Sharepoint服務(BDC服務)的代碼並在BDC元數據存儲中執行任何更新。 MSDN中,我發現這個樣本:如何從客戶端計算機連接到BDC服務

using (SPSite site = new SPSite("http://ssdk-server/Pages/Default.aspx")) 
{ 
    using (new Microsoft.SharePoint.SPServiceContextScope(SPServiceContext.GetContext(site))) 
    { 
     BdcService service = SPFarm.Local.Services.GetValue<BdcService>(String.Empty); 
     IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current); 

     IEntity entity = catalog.GetEntity("http://ssdk-server/sdksamples", "Customer"); 
     ILobSystemInstance LobSysteminstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value; 


     IView createView = entity.GetCreatorView("Create"); 
     IFieldValueDictionary valueDictionary = createView.GetDefaultValues(); 
     valueDictionary["Name"] = "some name"; 
     Identity id = entity.Create(valueDictionary, LobSysteminstance); 
    } 
} 

但是,這扔在第一線,出現異常:

FileNotFoundException (The Web application at http://sharepoint/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.). 

我發現了同樣的麻煩,但提出的解決方案(改變項目設置框架3.5,平臺到X64)不幫助我。

任何人都可以說我,是否有可能遠程連接到BDC服務,並將任何數據加載到元數據存儲,如果是這樣,我該怎麼做。

回答

1

以這種方式無法連接到遠程共享點服務器。 您應該使用Client Context

例如:

string siteUrl = "http://MyServer/sites/MySiteCollection"; 

    ClientContext clientContext = new ClientContext(siteUrl); 
    Web oWebsite = clientContext.Web; 
    ListCollection collList = oWebsite.Lists; 

    clientContext.Load(collList); 

    clientContext.ExecuteQuery(); 

    foreach (SP.List oList in collList) 
    { 
     Console.WriteLine("Title: {0} Created: {1}", oList.Title, oList.Created.ToString()); 
    } 

你會發現更多的例子here

+0

他是問如何連接到一個BDC服務遠程,而不是如何連接到一個簡單的SharePoint列表。你知道如何從C#CSOM應用程序連接到BDC服務嗎? – monkeyjumps

+0

@vmichael不,我不知道 –

相關問題