Siebel Object Interfaces Reference > Accessing Siebel COM Data Server with C++ >

Building the Siebel COM Client in C++

The following procedure explains how to build the Siebel COM Client in C++.

To build the Siebel COM client in C++

  1. In Microsoft Visual C++, choose File > New > Project.
  2. Select the MFC AppWizard (exe) project type.
  3. In the Project name field, enter SiebelCOM, and then click OK.

    The MFC AppWizard starts.

  4. Select the Dialog-based option and then click Next.
  5. In the "What other support would you like to include?" frame, check Automation and clear ActiveX Controls, and then click Next. Click Next again.
  6. Click Finish.

    Microsoft Visual C++ displays the project information.

  7. Click OK.

    The Application Wizard generates the standard MFC code that serves as the skeleton for this project. Headers and libraries necessary to support COM automation are included. Refer to the Microsoft Visual Studio [MSDN] documentation for a detailed description of the MFC libraries.

  8. The newly created dialog box appears in the workspace. You can resize the box and change the text in the label by editing its properties. Right-click the label in the dialog box to edit its properties. Modify the dialog box so that it looks something like the following illustration.
  9. Choose View > ClassWizard > Automation.
  10. Click Add Class > From a type library.
  11. Navigate to the SIEBSRVR_ROOT\bin folder. Choose sobjsrv.tlb.
  12. In the Confirm Classes dialog box, make sure all five Siebel classes are selected, and then click OK. Click OK again to close the Class Wizard.
  13. Add code to communicate with the Siebel COM Server.
    1. In the workspace window, click the FileView tab.
    2. Expand the Source Files and Header Files folders.
    3. Double-click the SiebelCOMDlg.h file.

      The code window opens.

    4. Add the following code highlighted in bold to the SiebelCOMDlg.h file:

    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000

    #include "sobjsrv.h" // Include Siebel wrapper classes

    class CSiebelCOMDlgAutoProxy;

    // CSiebelCOMDlg dialog

    class CSiebelCOMDlg : public CDialog{
      friend class CSiebelCOMDlgAutoProxy;
      SiebelApplication sApp; // Declare Siebel object

      CSiebelCOMDlg(CWnd* pParent = NULL); //standard constructor
      virtual ~CSiebelCOMDlg();

    1. Choose File > Open, and then select the SiebelCOMDlg.cpp file. Add the following code highlighted in bold to the OnInitDialog procedure:



    // TODO: Add extra initialization here
    // Start the Siebel Data Server
    if (!sApp.CreateDispatch(_T("SiebelDataServer.ApplicationObject)))
      AfxMessageBox("Cannot start Siebel Data Server.");
    EndDialog(-1); // Fail
    } else
      AfxMessageBox("Siebel Data Server initialized.");

    return TRUE; // Return TRUE unless you set the focus to a control

    1. In the same file, add the following code highlighted in bold to the OnOK procedure. Make sure that the line beginning with sApp.LoadObjects points to the location of the CFG file you intend to use. In the line beginning with sApp.Login, make sure that you have entered a valid logon name and password.

      void CSiebelCOMDlg::OnOK()

    short sErr;

    // Load configuration file
    // Make sure that the following line points to the correct file
    sApp.LoadObjects(C:\\siebel\\bin\\siebel.cfg", &sErr);
      AfxMessageBox("LoadObject failed.");
    } else
      AfxMessageBox("CFG file loaded.");

    // Log in as SADMIN
    sApp.Login("SADMIN", "SADMIN", &sErr);
      AfxMessageBox("Login failed.");
    } else
      AfxMessageBox("Logged into Siebel database.");

    // Get Account business object
    lpdBo = sApp.GetBusObject("Account", &sErr);
      AfxMessageBox("GetBusObject failed.");
    } else
      AfxMessageBox("Account business object retrieved.");
    SiebelBusObject Bo(lpdBo);

    // Get Account business component
    lpdBc = Bo.GetBusComp("Account", &sErr);
      AfxMessageBox("GetBusComp failed.");
    } else
      AfxMessageBox("Account business component retrieved.");
    SiebelBusComp Bc(lpdBc);

    // Get the name of the fist account
    if (sErr) return;
    if (sErr) return;
    Bc.SetSearchSpe("Name", "*", &sErr);
    if (sErr) return;
    Bc.ExecuteQuery(ForwardOnly, &sErr);
    if (sErr) return;
    if (sErr) return;

    // Display the account name in a message box
    CString csAcctName;
    csAcctName = Bc.GetFieldValue("Name", &sErr);

    Bc = null;
    lpdBc = null;
    Bo = null;
    lpdBo = null;


    if (CanExit())


When you have finished creating your program, test it to make sure it works properly.

Siebel Object Interfaces Reference Copyright © 2008, Oracle. All rights reserved.