I
iren_cui
Unregistered / Unconfirmed
GUEST, unregistred user!
delphi调用java写的web service,web service中方法返回一个javabean数组,在delphi程序中获取到的数组为空。
java代码。
public DicInfo[] getEventTypeRS(){
//返回获取的相关事件类型
ResultSet rs = null;
int taskCount = 0;
try{
logger.info("--------获取事件类型开始--------");
Date date = new Date();
long timer = date.getTime();
ReportEvent open = new ReportEvent();
String sSQL = "select count(*) as taskCount from umsys.tcDicEventType";
rs = open.openSQL(sSQL);
if (rs.next()){
taskCount = rs.getInt("taskCount");
}
//初始化bean定义数组
DicInfo[] arrInfo = new DicInfo[taskCount];
sSQL = "select EventTypeID, EventTypeName from umsys.tcDicEventType order by EventTypeID";
rs = open.openSQL(sSQL);
int i = 0;
DicInfo typeInfo = null;
while (rs.next()){
typeInfo = new DicInfo();
typeInfo.setTypeID(rs.getInt("EventTypeID"));
typeInfo.setTypeName(rs.getString("EventTypeName"));
arrInfo = typeInfo;
logger.info("[getEventTypeRS] ReturnValue: [EventTypeID = " + arrInfo.getTypeID() +
"] [EventTypeName = " + arrInfo.getTypeName() + "]");
i++;
}
date = new Date();
timer = date.getTime() - timer;
logger.info("获取事件类型结束,共获取" + taskCount + "条记录, 耗时:" + timer + "ms");
return arrInfo;
}catch (Exception e){
logger.error("[getEventTypeRS] Get EventType Failed! Error = [" + e + "]");
return null;
}
}
delphi代码
procedure TRegisterForm.Init(iDistricID: Integer);
var
sName: String;
iID, i: integer;
DicResult: ArrayOf_tns1_DicInfo;
DicLength: integer;
begin
try
begin
cmbEventType.AddItem('[请选择] ',TObject(-11));
WriteLog('GetEventTypeRS_begin');
DicResult := GetUMDXP.getEventTypeRS;
DicLength := Length(DicResult);
WriteLog('数组长度:' + IntToStr(DicLength));
for i := 0 to DicLength - 1 do
begin
iID := DicResult.typeID;
WriteLog('ID = ' + IntToStr(iID));
sName := DicResult.typeName;
WriteLog('Name = ' + sName);
cmbEventType.AddItem(sName, TObject(iID));
end;
WriteLog('GetEventTypeRS_end');
cmbMainType.AddItem('[请选择]', TObject(-11));
cmbSubType.AddItem('[请选择]', TObject(-11));
cmbEventType.ItemIndex := 0;
cmbMainType.ItemIndex := 0;
cmbSubType.ItemIndex := 0;
end
except
on E: Exception do
//ShowMessage('加载事件类型失败:' + E.Message);
WriteLog(E.Message);
end;
end;
java代码。
public DicInfo[] getEventTypeRS(){
//返回获取的相关事件类型
ResultSet rs = null;
int taskCount = 0;
try{
logger.info("--------获取事件类型开始--------");
Date date = new Date();
long timer = date.getTime();
ReportEvent open = new ReportEvent();
String sSQL = "select count(*) as taskCount from umsys.tcDicEventType";
rs = open.openSQL(sSQL);
if (rs.next()){
taskCount = rs.getInt("taskCount");
}
//初始化bean定义数组
DicInfo[] arrInfo = new DicInfo[taskCount];
sSQL = "select EventTypeID, EventTypeName from umsys.tcDicEventType order by EventTypeID";
rs = open.openSQL(sSQL);
int i = 0;
DicInfo typeInfo = null;
while (rs.next()){
typeInfo = new DicInfo();
typeInfo.setTypeID(rs.getInt("EventTypeID"));
typeInfo.setTypeName(rs.getString("EventTypeName"));
arrInfo = typeInfo;
logger.info("[getEventTypeRS] ReturnValue: [EventTypeID = " + arrInfo.getTypeID() +
"] [EventTypeName = " + arrInfo.getTypeName() + "]");
i++;
}
date = new Date();
timer = date.getTime() - timer;
logger.info("获取事件类型结束,共获取" + taskCount + "条记录, 耗时:" + timer + "ms");
return arrInfo;
}catch (Exception e){
logger.error("[getEventTypeRS] Get EventType Failed! Error = [" + e + "]");
return null;
}
}
delphi代码
procedure TRegisterForm.Init(iDistricID: Integer);
var
sName: String;
iID, i: integer;
DicResult: ArrayOf_tns1_DicInfo;
DicLength: integer;
begin
try
begin
cmbEventType.AddItem('[请选择] ',TObject(-11));
WriteLog('GetEventTypeRS_begin');
DicResult := GetUMDXP.getEventTypeRS;
DicLength := Length(DicResult);
WriteLog('数组长度:' + IntToStr(DicLength));
for i := 0 to DicLength - 1 do
begin
iID := DicResult.typeID;
WriteLog('ID = ' + IntToStr(iID));
sName := DicResult.typeName;
WriteLog('Name = ' + sName);
cmbEventType.AddItem(sName, TObject(iID));
end;
WriteLog('GetEventTypeRS_end');
cmbMainType.AddItem('[请选择]', TObject(-11));
cmbSubType.AddItem('[请选择]', TObject(-11));
cmbEventType.ItemIndex := 0;
cmbMainType.ItemIndex := 0;
cmbSubType.ItemIndex := 0;
end
except
on E: Exception do
//ShowMessage('加载事件类型失败:' + E.Message);
WriteLog(E.Message);
end;
end;