***A sample Client Code****
#include "Bank.hh"
#include "fstream.h"
CORBA::ORB_var global_orb = CORBA::ORB::_nil();
static CORBA::Object_ptr read_reference(const char* file)
{
cout << "File name: " << file << endl;
ifstream ifs("cref.dat");
//CORBA::String_var str;
char str[1000];
memset(str,'\0',1000);
ifs >> str;
cout << "str " << str << endl;
cout << "String len = " << strlen(str) << endl;
if( !ifs)
{
cerr << "Error reading from the file " << file << endl;
return CORBA::Object::_nil();
}
cout << "before return" << endl;
return global_orb->string_to_object(str);
}
int main(int argc, char **argv)
{
CORBA::Object_var tmp_ref;
try
{
global_orb = CORBA::ORB_init(argc,argv,"Orbix1");
const char* name = argc > 1 ? argv[1] : "Jack B. Quick";
tmp_ref = read_reference("./cref.dat");
cout << "Narrowing .." << endl;
Bank::AccountManager_var manager =
Bank::AccountManager::_narrow(tmp_ref);
if(CORBA::is_nil(manager))
{
cerr << " Count not narrow .. bad referece " << endl;
return 1;
}
cout << "Duplicating .. " << endl;
Bank::AccountManager_var acc_copy
(Bank::AccountManager::_duplicate(manager));
cout << "Opening ... " << endl;
// Request the account manager to open a named account.
Bank::Account_var account = manager->open(name);
cout << "Calling balance() " << endl;
// Get the balance of the account.
CORBA::Float balance;
balance = account->balance();
// Print out the balance.
cout << "The balance in " << name << "'s account is $"
<< balance << endl;
}
catch(const CORBA::Exception& e)
{
cerr << e << endl;
return 1;
}
}
****************************************************************
I just duplicated the object for the sake of trying but got the same
result.
The same client code works when i make a visibroker client out of it.
Just difference is ORB_init() parameter where I must pass something
like "Orbix" apart from argc,argv.
Rest all is same. But I get this error when I have orbix3 client.
10087-- Communication failure
- timeout
[ Completion status : COMPLETED_NO]
But I am able to do narrow succesfully...
Are there any compatibility issues between the Orbix 3 and
Visibroker6.0? Or I am missing something ?
Any suggestion would be of great help.
Thanks
Sachin.