I want to ask for help.
I need to write code that remotely connect to Sharepoint service(BDC service) and do any updates in BDC metadata store.
In msdn i found this sample:
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);
}
}
But, this thrown in first line with exception :
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.).
I found the same troubles, but proposed solutions(change project settings framework to 3.5, and platform to x64) don’t help me.
Can anyone say me, is that possible connect to BDC service remotely and load any data to metadata storeage, and, if so, how i can do that.
It is not possible to connect to remote sharepoint server this way.
You should use Client Context
for example:
you could find more examples here