java 代码
- public class HelloTestClient {
- /**
- * @param args
- */
- private static Context getInitialContext() throws Exception{
- String url = "t3://localhost:7001";
- String user = null;
- String password = null;
- Properties prop = new Properties();
- prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
- prop.put(Context.PROVIDER_URL, url);
- if(user != null){
- prop.put(Context.SECURITY_PRINCIPAL, user);
- prop.put(Context.SECURITY_CREDENTIALS, password == null?"":password);
- }
- return new InitialContext(prop);
- }
- public static void main(String[] args) throws Exception {
- Context ctx = getInitialContext();
- Object obj = ctx.lookup(HelloHome.JNDI_NAME);
- HelloHome helloHome = (HelloHome)PortableRemoteObject.narrow(obj, HelloHome.class);
- Hello hello = helloHome.create();
- System.out.println(hello.sayHello());
- }
- }