C++ Demonstration Programs

All the demonstration projects depend on the operation sample, so build it first.


operation

The operation sample consists of two Microsoft Visual C++ ATL App Wizard projects, operation1 and operation2. The operation1 project simply defines various UDTs and interfaces. The operation2 project defines coclasses that utilize the UDT and interface definitions from operation1. The operation2 project contains the following three coclasses:

With the corresponding default interfaces from the operation1 project:

You may use the operation sample to provide you with guidance on how to construct parameters of exceptionally complex data types.

C++ Client Projects

The service component is not the only Request Response Service or Subscription Service that can process operation request/documents published by testinterceptor. Any Request Response Service or Subscription Service can perform this processing for testinterceptor. Using the service component, however, provides an easy way to verify the operation of the adapter.

These exercises assume that you will use sample as the name of the dat file, and also assume that you will export sample.dat to the directory C:\tibco\adapter\adcom\5.3\examples. If you export it to a different directory, you must update the path in testinterceptor.dsw and rebuild your COM client before you import the metadata into the project file.

testinterceptor

This is an MSVC++ Win32 Console Application.

  1. Open the testinterceptor.dsw project in the examples\TestInterceptor directory. Set the testinterceptor project to active.
  2. Build the testinterceptor project, to generate the testinterceptor.exe executable.
  3. Start the service component of the adapter by typing the following line at the Microsoft Windows command prompt:
  4. adcomservice -system:repoURL "c:\tibco\adapter\adcom\5.3\examples\sample.dat" -system:configURL "Adapter for COM/Service Instances/TIBCOCOMService1"

  5. Run testinterceptor.exe. It will perform the following actions:
    1. Call CreateInstanceFromMoniker to obtain the ITestobj1, ITestobj2 and ITestobj3 interfaces. These interfaces are actually interceptor proxies.
    2. Call methods on the ITestobj1, ITestobj2 and ITestobj3 interfaces. These methods will result in TIBCO ActiveEnterprise operation requests or published documents being sent over TIBCO Rendezvous. These operation requests/documents will be received and processed by the service component.
      This example uses TIBCO Rendezvous. If you wish to use JMS, change the transport type to JMS.

testinterceptorCm

This is an MSVC++ Win32 Console Application.

  1. Open the testinterceptor.dsw project in the examples\TestInterceptor directory. Set the testinterceptorCm project to active.
  2. Build the testinterceptorCm project, causing the executable testinterceptorCm.exe to be generated.
  3. Start the service component of the adapter by typing the following line at the Microsoft Windows command prompt:
  4. adcomservice -system:repoURL "c:\tibco\adapter\adcom\5.3\examples\sampleCm.dat" -system:configURL "Adapter for COM/Service Instances/TIBCOCOMService1"

  5. Run testinterceptorCm.exe. It will perform the following actions:
    1. Call CreateInstanceFromMoniker to obtain the ITestobj1, ITestobj2 and ITestobj3 interfaces. These interfaces are actually interceptor proxies.
    2. Call methods on the ITestobj1, ITestobj2 and ITestobj3 interfaces. These methods will result in TIBCO ActiveEnterprise operation requests or published documents being sent over TIBCO Rendezvous using certified messaging. These operation requests/documents will be received and processed by the service component.

RecordSet Example

This section explains how to use the testinterceptor program (that ships with the example code), to test the ADODB RecordSet support provided by the adapter. This example uses the Microsoft SQL Server 2000 for the database support.

A sample server source code written in C++, which interacts with the database, is provided in the examples\Operation\Operation3 directory of the adapter installation.

The example in \Operation\Operation3 contains a OPERATION3 module that defines a class Testobj4.

The Testobj4 class contains only one method named GetRecordSet, which implements the functionality provided by the class. The GetRecordSet method of Testobj4 class takes two arguments and returns a ADODB RecordSet pointer. The first argument is the connection string and the second argument is the SQL query string.

The format of the connection string is similar to the following:

"user id= <User_id>;Provider=SQLOLEDB;Data Source= 
<Server_name>;Initial Catalog= <Database_name>;" 

The format of the query string is similar to the following:

"Select <column_names> from <table_name> where <conditions>" 

The TestInterceptor application is enhanced to contain a method called TestRecordSet that invokes TestObj4::GetRecordSet() when TEST_RECORDSET is defined in the project. Also, the project file Sample.dat, available in the examples directory contains additional metadata for the Operation3::TestObj4 class, and associated endpoint configurations.

To test the ADODB RecordSet support using the testinterceptor program:

  1. The TestRecordSet.sql available in the examples\Operation\Operation3 directory is an SQL script that creates a table and inserts some test records in that table.
  2. Run the Query Analyzer, open the SQL script, and execute that query.

    Also, you can run the query from the command prompt using the isqlw utility. For more information on isqlw, see the documentation that ships with Microsoft SQL Server 2000.

  3. Open and build the Operation\Operation3 project from the examples directory. Make sure that Operation3.dll is registered with the system.
  4. Open the TestInterceptor project using Microsoft Visual Studio. Modify the Connectionstring parameter for the database connection in the TestRecordSet method. Provide the User ID, Provider, Data Source, and Initial Catalog values according to your database server settings. By default, the recordset method call is not enabled in the project. Comment out the "#define TEST_RECORDSET" line to call the TestRecordSet method.

Connection Object Example

This section explains how the TIBCO ActiveEnterprise client (TIBCO BusinessWorks example) uses the ADO connection object implemented in the COM server.

This example uses Microsoft SQL Server 2000 for the database support.

COM Server Example in Microsoft VC++

A sample server source code written in C++, which interacts with the database, is available at the examples\TEAKExamples\ConnectionExample\VCExample\ConnectionServer directory of the adapter installation.

The COM server exposes an interface ITestConnection which has the following method:

  1. GetConnection([in] BSTR szConnectString, [in,out] _Connection** pConn);
  2. This method is called by the Client to get the Connection pointer from the server, by passing a valid connection string as the [in] parameter. The second parameter can be of type [in, out], [out, retval].

  3. GetData([in] BSTR szQueryString, [in, out] _Connection** pConn, [out, retval] _Recordset** pRecSet);
  4. This method is called by the Client to get a recordset by passing the connection pointer available from the GetConnection method and providing a proper query string as the [in] parameter. The second parameter can be of type [in] or [in,out].

  5. ReleaseConnection([in]_Connection* pConn);
  6. This method is called by the Client to release the connection object obtained from the GetConnection method.

COM Server Example for Microsoft Visual Basic

A sample server source code written in Microsoft Visual Basic, which interacts with the database, is available at the examples\TEAKExamples\ConnectionExample\VBExample\ConnectionServer directory of the adapter installation.

Its interface and method implementations are similar to the C++ COM server, but is written in Microsoft Visual Basic.

TIBCO ActiveEnterprise Client Example for C++ Server

Three TIBCO BusinessWorks process scenarios are provided as client examples. The repository file [RepoDir] is available at examples\TEAKExamples\ConnectionExample\VCExample. The corresponding dat file [repodata.dat] is available at examples\TEAKExamples\ConnectionExample\VCExample.

The project files can be opened in TIBCO Designer.

The three process scenarios are:

Running Connection Object Examples
  1. In each of the three example process scenarios, the Connection string input value of the Connection Activity, that is, the Activity which represents the GetConnection method, is given as DSN=AdoDemo;UID=sa;PWD=;.
  2. You must create a valid DSN by clicking Control Panel>Administrative Tools> Data Sources (ODBC), and change the connection string accordingly.

  3. The TestRecordSet.sql available in the examples\Operation\Operation3 directory is an SQL script that creates a table and inserts some test records in that table. Run the SQL Query Analyzer, open the SQL script, and execute that query.
  4. Also, you can run the query from the command prompt using the isqlw utility. For more information on isqlw, see the documentation that ships with Microsoft SQL Server 2000.

  5. Open Microsoft Visual Studio and build the COM server available at TEAKExamples\ConnectionExample\VCExample\ConnectionServerproject. Make sure that ConnectionServer.dll is registered with the system.
  6. Open the Multi-file project in TIBCO Designer and run the process scenarios.

TIBCO ActiveEnterprise Client Example for Visual Basic COM Server

The description and instructions for running this example are similar to the TIBCO ActiveEnterprise Client Example for C++ Server. The example is available at examples\TEAKExamples\ConnectionExample\VBExample.

C++ Troubleshooting

Problem: You may get the following error from either the service or interceptor component:

Error encountered (e2000042). MException thrown: Connection to TIB 
CR failed. Instance name attempted to is 
c:\tibco\adapter\adcom\5.3\examples\sample. 

Solution: You probably installed TIBCO Adapter for COM in a directory other than the default (c:\tibco\adapter\adcom). To allow the interceptor to find the repository, you need to edit the file main.cpp in the testinterceptor project and change all occurrences of the string c:\tibco\adapter\adcom\5.3\examples\sample.dat to point to the correct location of the repository file. To allow the service to find the repository, you must provide the correct value for the system:repourl command line switch.


TIBCO Adapter™ for COM User’s Guide
Software Release 5.3, September 2005
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com