[omniORB] (no subject)

Heinrich Götzger goetzger@gmx.net
Mon Jan 6 18:09:02 2003


On Mon, 6 Jan 2003, Olden A (SApS) wrote:

>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,

Take a look at 'src/examples/echo/eg3_clt.cc' and the corresponding docu
in the omniORB src distribution. It explains very well how this is
working.

chhers

Heinrich


>
>"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();
>      }
>}