[omniORB] Calling Weblogic component / RMI-IIOP
Richard Hardgrave
hardgrav@ttd.teradyne.com
Mon, 25 Jun 2001 10:06:07 -0500 (CDT)
> From owner-omniorb-list@uk.research.att.com Fri Jun 22 13:02 CDT 2001
> From: Shanmugam Deveraj <shm@transynergy.net>
> To: "'omniorb-list@uk.research.att.com'"
<omniorb-list@uk.research.att.com>
> Subject: [omniORB] Calling Weblogic component / RMI-IIOP
> Date: Fri, 22 Jun 2001 19:56:07 +0200
> MIME-Version: 1.0
> X-Loop: omniorb-list@uk.research.att.com
>
> 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?
I think you're missing the following code. See the
echo example, eg3_clt.cc.
// Obtain a reference to the root context of the Name service:
CORBA::Object_var obj;
obj = orb->resolve_initial_references("NameService");
>
> 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;
> }
>
>