rescueA

HttpInvoker客户端动态调用Demo
private static <T> T getHttpInvokerService(String serverUrl, Class<T> serviceInterface) {
HttpInvokerProxyFactoryBean httpInvoker = new HttpInvokerProxyFactoryBean();
httpInvoker.setServiceInterface(serviceInterface);
httpInvoker.setServiceUrl(serverUrl);
httpInvoker.afterPropertiesSet();
return (T) httpInvoker.getObject();
}

public static void main(String[] args){
  ITestService service = getHttpInvokerService("http://localhost:8080/remoting/ITestService",ITestService.class);
  System.out.println(service.getName());
}

posted on 2018-10-31 20:37  rescueA  阅读(632)  评论(0编辑  收藏  举报