通过webService调用另以系统。由于存在版本问题,所以这里用反射解决。不知道这样做的利弊,欢迎讨论。
private String getRemoteVersion(IService service) {
String version = null;
Class CHDMSInterFace = HDMSInterface.class;
Method MgetVersion = null;
//如果远程HDMS没有getVersion方法,则返回版本号为1.0
//(此处用异常处理流程,可优化)
try {
MgetVersion = CHDMSInterFace.getMethod("getVersion");
} catch (SecurityException e) {
logger.error(e);
} catch (NoSuchMethodException e) {
version = "1.0";
return version;
}
//如果版本不是1.0反射调用IService的getVersion方法返回版本号
try {
MgetVersion.invoke(service);
......下略