2012-10-08 72 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不,我不知道 –

相关问题