Business Data Catalog in Microsoft Office SharePoint Server 2007 and the Object Model
Microsoft Office SharePoint Services (MOSS) 2007 is Microsoft's innovative tool that provides the infrastructure to advance collaboration and communication within organizations based on the smooth flow of documents and information.
The Business Data Catalog (BDC), a fresh approach in SharePoint 2007, ensures integration between SharePoint and back-end systems such as databases as well as Line of Business (LOB) processes like SAP and Siebel applications.
There are two approaches for working with BDC: creating XML schemas manually or employing SharePoint's Object Model to programmatically interact with the LOB system.
The first part of the article, "Business Data Catalog in Microsoft Office SharePoint Server 2007: Architecture and Schemas," addresses the architecture within the Business Data Catalog and the creation of the BDC XML-based schema definitions. This section looks at SharePoint's Object Model and examines the tools for working with schemas, thus giving developers control over all aspects of the BDC.
NameSpaces and Classes
There are three NameSpaces that contain the main classes, methods and properties needed to exploit the capabilities of the Business Data Catalog from code:
- Microsoft.Office.Server.ApplicationRegistry.MetadataModel. Contains the classes necessary to read the Catalog objects and to execute queries. The classes are read-only and optimized to permit fast (read) access to the BDC.
- Microsoft.Office.Server.ApplicationRegistry.Runtime. Provides the object-oriented interface to access the components of the BDC schema. This abstraction layer simplifies the use of the XML schemas and ensures their programmability.
- Microsoft.Office.Server.ApplicationRegistry.Administration. Comprises the classes to create, update, and delete Business Data Catalogs metadata, but also may be used for reading. This NameSpace is used to manage schemas because its classes have read-write access to the Catalog. It is not advisable to use the NameSpace to read data because the output is not cached and is slower than the MetadataModel NameSpace. Changes made with the Administration NameSpace run with a SharePoint Timed Job; that means that the modifications can be applied after a short period of time.
There are three additional NameSpaces for the BDC:
- Microsoft.Office.Server.ApplicationRegistry.Infrastructure. Provides the classes for security and connections to physical sources of data.
- Microsoft.Office.Server.ApplicationRegistry.Search. This NameSpace is not documented by Microsoft and the MOSS Software Development Kit (SDK) marks it as "reserved for internal use."
- Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db. Contains two classes for manipulating entities instances in Data Bases and one not documented class.
In addition to using the Object Model, there are also a number of standard WebServices for the Business Data Catalog grouped under the Microsoft.Office.Server.ApplicationRegistry.WebService NameSpace. The ten classes of the NameSpace are noted as "reserved for internal use and not intended to be used directly from your code" by the MOSS SDK. Note that there is no supplementary documentation available in the MOSS SDK, but it is certainly possible to use them; however, caution is advised. For example, the class "BdcWebService" has methods to read LOB system instances, entities, and methods. The WebService can be reached from IIS under the URL 'http://[ServerName]/_vti_bin/businessdatacatalog.asmx'.
BDC Schema under the Loop
The Business Data Catalog is a constituent part of the MOSS Shared Services Provider (SSP), so the first action in the code is to make a connection to the SSP that holds the BDC schema:
The only parameter of the "SqlSessionProvider" is a string with the name of the Shared Service, "SharedServices1", in the above example, the default name for the first SSP. Note that it is only possible to make a connection in the local farm.
Note: The next example is a Visual Studio 2005 console application project. Make references in the project to "Microsoft.Office.Server" ("Microsoft.Office.Server.dll") and "microsoft.sharepoint.portal" ("Microsoft.SharePoint.Portal .dll"), and directives at the beginning of the code page to:using Microsoft.Office.Server.ApplicationRegistry.MetadataModel; using Microsoft.Office.Server.ApplicationRegistry.Infrastructure; using Microsoft.Office.Server.ApplicationRegistry.Runtime; using Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db; using myAdmin = Microsoft.Office.Server.ApplicationRegistry.Administration;
The directive to the Administration NameSpace has a special name ("myAdmin") to avoid a conflict with methods from the Runtime and MetadaModel NameSpaces. An extra directive to "using System.Data" may be necessary.
In the following code samples, the hypothetical zoo Business Data Catalog from the first article will be used. The information is read from a SQL database and is displayed in the BDC WebParts of the portal:
Figure 1: Information from "MyZoo" DataBase ("AnimalsEntity List") in the portal
Page 1 of 4