同一个容器和不同容器的方法应该不一样吧,能介绍下吗,讲下大概用到的技术和原理就OK

解决方案 »

  1.   

    http://www.google.com/search?hl=zh-CN&q=webservice&btnG=Google+%E6%90%9C%E7%B4%A2&lr=
      

  2.   

    webservice
    如果都是java的也可以用ejb,rmi
      

  3.   

    我们最常用的是ejb,可以用里面的远程方法调用,配置好jndi指向你的项目具体路径就可以啦。
      

  4.   

    ejb可以实现,但是太庞大,是重量级的可以选择spring来实现,还可以通过webservice
      

  5.   

    谢谢楼上几位的建议,现在问题来了
    我用了ejb3.0来实现
    projectA中:CommandCalculate.class
    package clientapp;
    public interface CommandCalculate {
        public void test();
    }CommandCalculateRemote.class
    package clientapp;
    import javax.ejb.Remote;
    @Remote
    public interface CommandCalculateRemote extends CommandCalculate{ 
    }CommandCalculateBean.class
    package clientapp;
    import javax.ejb.Stateless;
    @Stateless
    public class CommandCalculateBean implements CommandCalculateLocal,CommandCalculateRemote{
        public void test(){
            System.out.println("xxx");
        }
    }CommandCalculate.class和CommandCalculateRemote.class打成了jar导入了projectBprojectB中:try {
                Properties props = System.getProperties();
                props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
                props.put(Context.URL_PKG_PREFIXES, "com.sun.enterprise.naming");
                props.put(Context.STATE_FACTORIES,"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
                props.put(Context.PROVIDER_URL, "iiop://22.117.79.139:3700");
                InitialContext ctx = new InitialContext(props);
                System.out.println(CommandCalculateRemote.class.getName());
                CommandCalculate cc = (CommandCalculate) ctx.lookup(CommandCalculateRemote.class.getName());
                cc.test();
            } catch (Exception e) {
                e.printStackTrace();
            }
    本人用的glassfish,问题来了,本机(同一个容器中)测试通过,确实可以调到打印出"xxx",但projectB部署到另一台机器后就报出如下错误:
    javax.naming.NameNotFoundException: com.jas.clientapp.CommandCalculateRemote not found
    不知何解,赐教~~
      

  6.   


    对!!速度快加上缓存配置,速度根本不差,webservice多慢呀!那是一个方法级别的。如果不是,http就可以了返回JSON字符就可以数据通信了!
      

  7.   

    谢谢楼上几位的建议,现在问题来了 
    我用了ejb3.0来实现 
    projectA中: CommandCalculate.class 
    package clientapp; 
    public interface CommandCalculate { 
        public void test(); 
    } CommandCalculateRemote.class 
    package clientapp; 
    import javax.ejb.Remote; 
    @Remote 
    public interface CommandCalculateRemote extends CommandCalculate{ 
    } CommandCalculateBean.class 
    package clientapp; 
    import javax.ejb.Stateless; 
    @Stateless 
    public class CommandCalculateBean implements CommandCalculateLocal,CommandCalculateRemote{ 
        public void test(){ 
            System.out.println("xxx"); 
        } 
    } CommandCalculate.class和CommandCalculateRemote.class打成了jar导入了projectB projectB中: try { 
                Properties props = System.getProperties(); 
                props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory"); 
                props.put(Context.URL_PKG_PREFIXES, "com.sun.enterprise.naming"); 
                props.put(Context.STATE_FACTORIES,"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"); 
                props.put(Context.PROVIDER_URL, "iiop://22.117.79.139:3700"); 
                InitialContext ctx = new InitialContext(props); 
                System.out.println(CommandCalculateRemote.class.getName()); 
                CommandCalculate cc = (CommandCalculate) ctx.lookup(CommandCalculateRemote.class.getName()); 
                cc.test(); 
            } catch (Exception e) { 
                e.printStackTrace(); 
            } 
    本人用的glassfish,问题来了,本机(同一个容器中)测试通过,确实可以调到打印出"xxx",但projectB部署到另一台机器后就报出如下错误: 
    javax.naming.NameNotFoundException: com.jas.clientapp.CommandCalculateRemote not found 
    不知何解,赐教~~
      

  8.   

    为什么不尝试下ESB(Enterprise Service Business)。ALSB是实现ESB的一个容器。
      

  9.   

    http、webservice 都可以实现