• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Basic CORBA Help

 
Alan Jackson
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Im new to distributed java, and Im currently working with some CORBA stuff and Im needing some help.

Im trying to pass in a hard coded long and have it sent back as a string with a little bit of text after it. My code is shown below. Im always getting a problem with my Operations file produced with "(greeting.sayHello())" as the problem - "sayHello(long) cannot be applied.

Im sure its just some way Ive defined something, but Id really appreciate it if someone could help me out.

IDL:
------
interface Greeting {
string sayHello(in long long msg);
};


CLIENT:
--------
long msg = 2;
Object nameService = orb.resolve_initial_references("NameService");
NamingContext nameCtx = NamingContextHelper.narrow(nameService);
NameComponent [] name = {new NameComponent("MyGreetingServant", "")};
Object servant = nameCtx.resolve(name);

Greeting greeting = GreetingHelper.narrow(servant);
System.out.println(greeting.sayHello());
} catch (Exception e) {
System.out.println(e);
}
}
}


SERVER
--------
public static void main (String [] args) {
try {
ORB orb = ORB.init(args, null);
GreetingImpl greetingServant = new GreetingImpl();
org.omg.CORBA.Object obj = orb.resolve_initial_references("RootPOA");
POA poa = (POA)obj;
poa.the_POAManager().activate();
org.omg.CORBA.Object greetingObj = poa.servant_to_reference(greetingServant);


org.omg.CORBA.Object nameService = orb.resolve_initial_references("NameService");
NamingContext nameCtx = NamingContextHelper.narrow(nameService);
NameComponent [] name = {new NameComponent("MyGreetingServant","")};
nameCtx.bind(name, greetingObj);

orb.run();
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
}


IMPL:
------
public class GreetingImpl extends GreetingPOA {
public String sayHello(long msg) {
String mess;
mess = (msg + "from Impl");
return mess;
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic