[omniORB] Calling Weblogic component / RMI-IIOP

Shanmugam Deveraj shm@transynergy.net
Fri, 22 Jun 2001 19:56:07 +0200


Hi

Can anyone help in calling a weblogic 6.0 component from omniorb c++
client?

call to resolve fails? but the helloserver is started in weblogic and it
seems to be running.

Is this the way to use naming context?

Regards,
Shanmugam.D.

int main(int argc, char* const* argv)
{
  try {
    CORBA::ORB_var orb = CORBA::ORB_init(argc, (char**)argv,
"omniORB3");
    if (argc != 2) {
  		cout << "Usage: HelloClient <ServerIOR>" << endl;
	  	return argc;
    }
    // obtain WebLogic Server IOR from command line argument
    const char* ior = argv[1];

    // string to object
    CORBA::Object_ptr obj = orb->string_to_object(ior);
	  if( CORBA::is_nil(obj) ) {
		  cerr << "Failed to narrow the object pointer." <<
endl;
		  return 0;
	  }

    // obtain a naming context
    CosNaming::NamingContext_var context =
CosNaming::NamingContext::_narrow(obj);
  	if( CORBA::is_nil(context) ) {
	  	cerr << "Failed to narrow the object pointer." << endl;
		  return 0;
	  }

    CosNaming::Name name;
    name.length(1);
    name[0].id = "HelloServer_iiop";
    name[0].kind = "";

    // resolve and narrow to RMI object
    CORBA::Object_var object = context->resolve(name);

    examples::rmi_iiop::hello::HelloWorld_var hi = 
      examples::rmi_iiop::hello::HelloWorld::_narrow(object);

    if(!CORBA::is_nil(hi)) {
      cout << "Before calling sayHello..." << endl;
      hi->sayHello();
    }
  }
	catch(CORBA::SystemException& ex) {
		cerr << "Caught CORBA::SystemException." << endl;
	}
	catch(CORBA::Exception &ex) {
		cerr << "Caught CORBA::Exception." << endl;
	}
	catch(omniORB::fatalException& fe) {
		cerr << "Caught omniORB::fatalException:" << endl;
		cerr << "  File: " << fe.file() << fe.line() << endl;
		cerr << "  Message: " << fe.errmsg() << endl;
	}
	catch(...) {
		cerr << "Caught unknown exception." << endl;
	}

  // Clean up all the resources.
  orb->destroy();

  return 0;
}