[omniORB] Problem with omniORBpy and NamingService

Sai-Lai Lo s.lo@uk.research.att.com
Wed, 25 Jul 2001 14:01:54 -0000


Please read Q20 of the FAQ.


----- Original Message -----
From: "marc" <marc@xena.nekhem.fr>
To: <omniorb-list@uk.research.att.com>
Sent: Wednesday, July 25, 2001 1:33 PM
Subject: [omniORB] Problem with omniORBpy and NamingService


> I use omniORBpy with omniORB3 on Linux. I work with the NamingService. If
I put the server and the client on the local host, it ru very well. But if I
put the server on a remote host on the same network, the exception
"omniORB.CORBA.COMM_FAILURE: Minor: 32, Completed: COMPLETED_NO." from the
client, appears. I tried to change the configuration in the omniorb.cfg
file, but I always obtained the same result.
> I don't understand why it's not working.
>
> I put my scripts below:
>
>
> ##################### IDL
>
> module User {
>   interface Information {
>     readonly attribute string name;
>     readonly attribute string surname;
>     attribute float salary;
>
>     string getName();
>     string getSurname();
>     float getSalary();
>     float increaseSalary( in float inc_value );
>     float decreaseSalary( in float dec_value );
>   };
> };
>
> ##################### Server.py
>
> import sys
> from omniORB import CORBA, PortableServer
> import User, User__POA
> import CosNaming
>
> # Define implementation of the Information interface
>
> class Information_s ( User__POA.Information ) :
>     def __init__ ( self ):
>         self.name = "Eric"
>         self.surname = "Bianchi"
>         self.salary = 100.0
>
>     def getName ( self ):
>         print """getName"""
>         return self.name
>
>     def getSurname ( self ):
>         print """getSurName"""
>         return self.surname
>
>     def getSalary ( self ):
>         print """getSalary"""
>         return float(self.salary)
>
>     def increaseSalary ( self, inc_value ):
>         print """increaseSalary"""
>         self.salary = self.salary + inc_value
>         return float(self.salary)
>
>     def decreaseSalary ( self, dec_value ):
>         print """decreaseSalary"""
>         self.salary = self.salary - dec_value
>         return float(self.salary)
>
> # Initialise the ORB:
> orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
> poa = orb.resolve_initial_references("RootPOA")
>
> # Create an instance of Information_s and an Information object reference:
>
> ifts = Information_s()
> ift = ifts._this()
> print """New Information object has been created"""
> print ift
>
> # Obtain a reference to the root naming context:
>
> obj         = orb.resolve_initial_references("NameService")
> rootContext = obj._narrow(CosNaming.NamingContext)
>
> if rootContext is None:
>     print 'Failed to narrow the root naming context'
>     sys.exit(1)
>
> # Bind a context named "test.my_context" to the root context:
>
> name = [CosNaming.NameComponent("test", "my_context")]
> try:
>     testContext = rootContext.bind_new_context(name)
>     print "New test context bound"
>
> except CosNaming.NamingContext.AlreadyBound, ex:
>     print "Test context already exists"
>     obj = rootContext.resolve(name)
>     testContext = obj._narrow(CosNaming.NamingContext)
>     if testContext is None:
>         print "test.mycontext exists but is not a NamingContext"
>         sys.exit(1)
>
> # Bind the Information object to the test context:
> name = [CosNaming.NameComponent("UserInformation", "Object")]
> try:
>     testContext.bind(name, ift)
>     print "New UserInformation object bound"
>
> except CosNaming.NamingContext.AlreadyBound:
>     testContext.rebind(name, ift)
>     print "UserInformation binding already existed -- rebound"
>
> # Activate the POA
> poaManager = poa._get_the_POAManager()
> poaManager.activate()
>
> # Block for ever (or until the ORB is shut down)
> orb.run()
>
> #################### Client.py
>
> import sys
> from omniORB import CORBA
> import User
> import CosNaming
>
> # Initialise the ORB
> orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
>
> # Obtain a reference to the root naming context
> obj         = orb.resolve_initial_references("NameService")
> rootContext = obj._narrow(CosNaming.NamingContext)
>
> if rootContext is None:
>     print "Failed to narrow the root naming context"
>     sys.exit(1)
>
> # Resolve the name "test.my_context/UserInformation.Object"
> name = [CosNaming.NameComponent("test", "my_context"),
> CosNaming.NameComponent("UserInformation", "Object")]
> try:
>     obj = rootContext.resolve(name)
>
> except CosNaming.NamingContext.NotFound, ex:
>     print "Name not found"
>     sys.exit(1)
>
> # Narrow the object to an User::Information
> ift = obj._narrow(User.Information)
> print ift
> if ift is None:
>     print "Object reference is not an User::Information"
>     sys.exit(1)
>
> #Invoke getName operation
> print 'the user is :\n'
> name = ift.getName()
> print 'Name: ', name
>
> surname = ift.getSurname()
> print 'Surname: ', surname
>
> salary = ift.getSalary()
> print 'Salary: ', salary
>
> x = ''
> while not x:
>     x = int(raw_input('Increase or decrease the salary? 1 or 2:'))
>
>     if x == 1:
>         y = ''
>         while not y:
>             y = float(raw_input('salary increased value;\n'))
>             salary = ift.increaseSalary(y)
>             print 'The new salary is:\n', salary
>
>     if x == 2:
>         y = ''
>         while not y:
>             y = float(raw_input('salary decreased value;\n'))
>             salary = ift.decreaseSalary(y)
>             print 'The new salary is:\n', salary
>
>  ######################################################################
>
> The client answer me:
>
> Traceback (innermost last):
>   File "client.py", line 36, in ?
>     name = ift.getName()
>   File "User_idl.py", line 67, in getName
>     return _omnipy.invoke(self, "getName", _0_User.Information._d_getName,
args)
> omniORB.CORBA.COMM_FAILURE: Minor: 32, Completed: COMPLETED_NO.
>
>
>
> --
> Marc
> --
>
>
>