aspose file tools*
The moose likes Distributed Java and the fly likes Basic CORBA Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Basic CORBA Help" Watch "Basic CORBA Help" New topic
Author

Basic CORBA Help

Alan Jackson
Greenhorn

Joined: Oct 26, 2004
Posts: 26
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;
}
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Basic CORBA Help