|
 |
pro_java_server thread: RE: How to resolve hostname when calling CORBA object
Message #1 by Chanoch Wiggers <ChanochW@w...> on Thu, 5 Apr 2001 18:11:11 +0100
|
|
This should be a simple as finding the IP address or network name of the
computer on which the server is running and pass that as the reference.
I assume that the microsoft client is running on the same machine as the
server, right? (if you need help with that you are probably running a win
machine - if you tell me what your setup is I'll try to help) in that case
it would be using localhost to resolve to the loopback address. If your java
client is running on the same machine as the CORBA server you should be able
to use localhost or 127.0.0.1 I think the java code checks whether you have
passed an IP address or a server name automatically so you should be able to
use either.
chanoch
-----Original Message-----
From: Lucky Door [mailto:luckydoor@y...]
Sent: 21 March 2001 16:43
To: Java Server
Subject: How to resolve hostname when calling CORBA object
I am trying to create a java client to communicate with
orbix object created with C++. I checked the C++ client
and it communicate with server via NameService without
specifying "hostname". In java code (from Wrox book), I
see the client code has to specify hostname where the
CORBA server resides.
sample code from wrox book:
// Client implementation
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
public class TestClient {
public static void main(String[] args) {
try {
// initialize ORB
ORB orb = ORB.init(args, null);
// connecting to the Naming Service
org.omg.CORBA.Object contextObj =
orb.resolve_initial_references("NameService");
NamingContext rootContext
=
NamingContextHelper.narrow(contextObj);
// get object reference
NameComponent name = new NameComponent("Test", "");
NameComponent path[] = {
name
};
// retreive object
org.omg.CORBA.Object obj = rootContext.resolve(path);
Test testObj = TestHelper.narrow(obj);
// invoke methods
short result1 = testObj.method1((short) 1, "Test");
String result2 = testObj.method2((short) 1, "Test");
System.out.println("Result 1 is " + result1);
System.out.println("Result 2 is " + result2);
// release object
testObj._release();
} catch (Exception e) {
System.err.println("Exception : " + e);
e.printStackTrace(System.err);
}
}
}
to run the client, I have to specify the hostname:
java TestClient -ORBInitialPort <X> -ORBInitialHost <hostname>
How can I locate the server if I don't know the hostname via
Naming Service?
Thanks,
|
|
 |