Tuesday, April 17, 2012

Oracle BDC Catalog Import headaches

Oracle BDC and .Net Connectivity with LOB Systems

For one of my clients I had to get the data connectivity to Oracle database. This is one of those connections that you think it is easy and not much to figure out.....well you are wrong. Atleast I was. There is not much doucmentation explaining about this either..it was frustrating for me to figure this out.

ULS Errors sometimes are not that clear on what is happennig.

Assembly was requested for LobSystem with Name 'XXXXXX', but this assembly was not returned. 
SystemUtility of Type
'Microsoft.SharePoint.BusinessData.SystemSpecific.DotNetAssembly.DotNetAssem
blySystemUtility' requires the assembly to be uploaded.    


Well here it is...I will try to give you as much detail as possible so that you can have a smooth connectivity.
You should be familiar on BDC connectivity a bit.

What is involved.
  1. BDC Model explaining entities that are involved getting data from Oracle. (Bunch of XML)
  2. Few PowerShell commands to hook up the Entity (Do not worry....you will get it in  a minute)
Good References...
I really liked Vijai Anand article in C# corner. He walked through in very detail steps. I liked it.

BDC Model:
Using Visual Studio:

First create a new project (Business Data Connectivity Model).








Accept the default but make sure the site name is where you want this to be.



Visual Studio will give you two classes and one bdcm file as shown below. I modified the names of the .cs files and the data accordingly. This data depends on your data from Oracle. So I just gave some simple example.



Open the BDCModel1.bdcm file with XML Viewer. (Right mouse click on the file "BDCModel1.bdcm" and select "Open With..." and select XML Viewer.

Do the necessary modifications according to your objects or choose to use SharePoint designer to construct the XML as shown below. On how to construct XML please refer the following...
http://sethnidhi.blogspot.com/
http://msdn.microsoft.com/en-us/library/ff464424.aspx

My main goal is to show you how to extract/import LOBSystem out of our Oracle BDC.

Within the XML Notice the LOBSystem XML Tags  with Name and Type attributes. We need the value of Name attribute.



Once you install the the BDC and got your Content types established for the data from Oracle, now you are ready to Import the LObSystem.

Open your SharePoint Power Shell window and follow the below scripts to import.


$site = new-object "Microsoft.SharePoint.SPSite" "http://YourSite/sites/YourSubSite/"


$serviceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site) 


$bdcService = new-object "Microsoft.SharePoint.BusinessData.SharedService.BdcService"


$catalog = $bdcService.GetAdministrationMetadataCatalog($serviceContext) 


$lobsystem = $catalog.GetLobSystem("LobSystemName")  
                      Comment: LobSystemName from the Name attribute of LobSystem XML. i.e. BDCModel1


Import-SPBusinessDataCatalogDotNetAssembly -Path "C:\Project\ProjectSolution.dll" -LobSystem $lobsystem
                            Comment: This is the dll of your project. You can extract from solution file (wsp) and place it in a folder                           and point to it.




That is it. To test your connectivity..
Create a list based on the External List template. Choose the content type and you should be able to see the data.

Hope this helps.

Good Luck.







No comments:

Post a Comment