[omniORB] (no subject)
baileyk@schneider.com
baileyk@schneider.com
Mon Jan 6 18:38:01 2003
Just a quick look and I see
CosNaming::NamingContextExt ncRef;
Which should be
CosNaming::NamingContextExt_ptr ncRef;
or
CosNaming::NamingContextExt_var ncRef;
Probably a case of thinking in terms of the Java binding for IDL while
writing C++ code.
Kendall
"Olden A (SApS)"
<aolden@glam.ac.uk> To: omniorb-list@omniorb-support.com
Sent by: cc:
omniorb-list-admin@omniorb-s Fax to:
upport.com Subject: [omniORB] (no subject)
01/06/2003 10:40 AM
Hi Folks,
How do I use the NamingContextExt with omniORB (or it could be a "with
C++"), I have a JAVA server (some of the code is given below) which works
using the JAVA client (using Omninames), but the client uses
NamingContextExt, and whenever I try it in c I get an error buring
compilation,
"binary 'a' : no operator defined takes a right hand operand type class
CosNaming::_objRef_NamingContextExt"
the code is:
int main(int argc, char* argv[])
{
// Initalize The Orb.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CosNaming::NamingContext_var rootContext;
CosNaming::NamingContextExt ncRef;
CORBA::Object_var obj;
obj = orb->resolve_initial_references("NameService");
cerr << "Resolved Initial References.." << endl;
rootContext = CosNaming::NamingContext::_narrow(obj);
// NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
ncRef = CosNaming::NamingContextExt::_narrow(rootContext);
}
and the java code, which is basicllt what I'm trying to recreate (with a
lot more objects) is:
Properties props = new Properties();
props.put("org.omg.CORBA.ORBInitialHost", "bslap");
props.put("org.omg.CORBA.ORBInitialPort", "2809");
// Set Up The ORB
ORB orb = ORB.init(args,props);
// Get The Naming Context
org.omg.CORBA.Object objRef = orb.resolve_initial_references
("NameService");
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
phsensor = Sensor_DetailsHelper.narrow(ncRef.resolve_str("PH"));
phsensor.setSesnorID(0);
which access the server:
public class Server
{
public static void main(String args[])
{
Properties props = new Properties();
props.put("org.omg.CORBA.ORBInitialHost", "bslap");
props.put("org.omg.CORBA.ORBInitialPort", "2809");
// Initalize The ORB
ORB orb = ORB.init(args,props);
// Initalize The POA
POA poa = POAHelper.narrow(orb.resolve_initial_references
("RootPOA"));
poa.the_POAManager().activate();
POA poa2 = POAHelper.narrow(orb.resolve_initial_references
("RootPOA"));
poa2.the_POAManager().activate();
Sensor_ObjectImpl phsensor = new Sensor_ObjectImpl();
// Work With PH:
org.omg.CORBA.Object ref = poa.servant_to_reference(phsensor);
Sensor_Details href = Sensor_DetailsHelper.narrow(ref);
org.omg.CORBA.Object objRef = orb.resolve_initial_references
("NameService");
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
String name = "PH";
NameComponent path[] = ncRef.to_name(name);
ncRef.rebind(path,href);
orb.run();
}
}