Siebel Object Interfaces Reference > Programming > Getting Started with the Siebel Object Interfaces >
Instantiating the Siebel COM Data Server
Because the Siebel COM Data Server acts without the regular Siebel Business Application User Interface, you must use the Login method to set up your Data Server object. You cannot use methods that retrieve active Siebel objects, because there are no current active Siebel objects. You must instantiate your own Siebel objects. Calls made to the Siebel COM Data Server are in process. If you use Microsoft Visual Basic 5.0 or later, the required support file, sobjsrv.tlb , must be in the same directory as the CFG file you are using for your Siebel application, or the COM Data Server does not work. Take the following steps to make sure you are referring to the correct library. NOTE: Do not run in the Microsoft VB Debug environment when communicating with the Siebel COM Data Server.
When using COM Data Server, the COM client cannot create multiple connections to the COM Server. The COM client must be restarted before another connection attempt can be successful. Use COM Data Control instead. To set up Microsoft Visual Basic to access the Siebel COM Data Server
- Start Microsoft Visual Basic.
- Select Standard EXE.
- Choose Project > References.
- In the dialog box that appears, click on Siebel Data BusObject Interfaces, but do not check its checkbox. Near the bottom of the dialog box, note the directory in which the file sobjsrv.tlb resides, as shown in the following illustration.
- Select the Siebel Data BusObject Interfaces checkbox, and then click OK.
The following is sample code for the Siebel COM Data Server. Make sure that the DataSource parameter in the CFG file is set to the database to which you want to connect. NOTE: This code must be written and executed outside of Siebel Tools, for example in Microsoft Visual Basic.
Private Sub Command1_Click() 'Siebel Application Object Dim siebApp As SiebelApplication Dim siebBusObj As SiebelBusObject Dim siebBusComp As SiebelBusComp Dim siebSvcs As SiebelService Dim siebPropSet As SiebelPropertySet Dim bool As Boolean Dim errCode As Integer Dim errText As String Dim connStr As String Dim lng As String Dim cfgLoc As String
ChDrive "D" ChDir "D:\Server\siebsrvr\bin"
'Create The COM Data Server Object Set siebApp = CreateObject("SiebelDataServer.ApplicationObject")
If Not siebApp Is Nothing Then
'''COM Data Server cfgLoc = " D:\Server\siebsrvr\bin \ENU\siebel.cfg,ServerDataSrc" siebApp.LoadObjects cfgLoc, errCode If errCode = 0 Then 'Log Into the Siebel Server siebApp.Login "username", "password", errCode If errCode = 0 Then 'Creat A Business Object Set siebBusObj = siebApp.GetBusObject("Contact", errCode) If errCode = 0 Then 'Create a Business Component Set siebBusComp = siebBusObj.GetBusComp("Contact") Else errText = siebApp.GetLastErrText siebApp.RaiseErrorText("Business Object Creation failed: " & errCode & "::" & errText); End If
'Create A New Property Set Set siebPropSet = siebApp.NewPropertySet(errCode) If errCode = 0 Then Set siebPropSet = Nothing Else errText = siebApp.GetLastErrText siebApp.RaiseErrorText("Property Set Creation failed: " & errCode & "::" & errText); End If
'Get A Siebel Service Set siebSvcs = siebApp.GetService("Workflow Process Manager", errCode) If Not siebSvcs Is Nothing Then Set siebSvcs = Nothing Else errText = siebApp.GetLastErrText siebApp.RaiseErrorText("Could not Get Siebel Service: " & errCode & "::" & errText); End If
If Not siebBusComp Is Nothing Then Set siebBusComp = Nothing End If If Not siebBusObj Is Nothing Then Set siebBusObj = Nothing End If Else errText = siebApp.GetLastErrText siebApp.RaiseErrorText("Login Failed: " & errCode & "::" & errText); End If Else errText = siebApp.GetLastErrText siebApp.RaiseErrorText("Load Objects Failed: " & errCode & "::" & errText); End If
Set siebApp = Nothing
End If
End Sub
|