package test.httprmi; import java.util.Arrays; import org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor; import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean; import ch.systemsx.cisd.lims.base.DataSetInformation; import ch.systemsx.cisd.lims.base.ExternalData; import ch.systemsx.cisd.lims.base.IETLLIMSService; import ch.systemsx.cisd.lims.base.ILIMSService; import ch.systemsx.cisd.lims.base.MaterialType; import ch.systemsx.cisd.lims.base.ProcedureTypeCode; public class RMIHttpClient { public static void main(String[] args) { String baseURL = System.getProperty("lims.rmi.base.url", "http://localhost:8888/"); ILIMSService limsService = createLIMSServiceStub(baseURL); IETLLIMSService etlLIMSService = createETLLIMSServiceStub(baseURL); System.out.println("version:"+limsService.getVersion()); String cred = limsService.authenticate("RMI.over.HTTP", "Test", "DEFAULT"); System.out.println(cred); MaterialType[] materialTypes = limsService.listMaterialTypes(cred); System.out.println(Arrays.asList(materialTypes)); System.out.println("version:"+etlLIMSService.getVersion()); String token2 = etlLIMSService.authenticate("user", "pswd", "3V"); System.out.println("token:"+token2); System.out.println("isSampleRegistered:"+etlLIMSService.isSampleRegisteredForDataSet(token2, "data42")); DataSetInformation dataSetInformation = new DataSetInformation(); dataSetInformation.setSampleCode("sample code"); ExternalData externalData = new ExternalData(); String code = ProcedureTypeCode.DATA_ACQUISITION.getCode(); etlLIMSService.registerDataSet(token2, dataSetInformation, code, externalData); } private static ILIMSService createLIMSServiceStub(String baseURL) { HttpInvokerProxyFactoryBean httpInvokerProxy = new HttpInvokerProxyFactoryBean(); httpInvokerProxy.setServiceUrl(baseURL + "rmi"); httpInvokerProxy.setServiceInterface(ILIMSService.class); httpInvokerProxy.setHttpInvokerRequestExecutor(new CommonsHttpInvokerRequestExecutor()); httpInvokerProxy.afterPropertiesSet(); return (ILIMSService) httpInvokerProxy.getObject(); } private static IETLLIMSService createETLLIMSServiceStub(String baseURL) { HttpInvokerProxyFactoryBean httpInvokerProxy = new HttpInvokerProxyFactoryBean(); httpInvokerProxy.setServiceUrl(baseURL + "rmi-etl"); httpInvokerProxy.setServiceInterface(IETLLIMSService.class); httpInvokerProxy.setHttpInvokerRequestExecutor(new CommonsHttpInvokerRequestExecutor()); httpInvokerProxy.afterPropertiesSet(); return (IETLLIMSService) httpInvokerProxy.getObject(); } }