!急!!delphi调用web service参数传递出错(100分)

  • 主题发起人 主题发起人 iren_cui
  • 开始时间 开始时间
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调用这个service,没问题
我试过delphi调用同样的delphi写的service,没问题

不知道用delphi调用java 的 webservice为什么不行,获取到的数组为空。
 
达人相助啊[:)]
 
可能是字符编码的问题 delphi的vcl不是用的unicode
 
是不是中文与英文的问题呀
 
99%是参数名称的问题,上次我用DELPHI写一个WebService,Java调用,也出现一样的问题,通过抓包工具观察发现,我写的函数中参数名称是 Name,Psd Java传入的参数名称是agr1,agr2,我查了查资料,这参数名称在Java中还没法设置,真不知道有多丢人.....
 
谢谢ball_cao,yjwnnit,已经确定跟字符 中英文等问题无关.
skaly提供的信息很有启发,能不能简单说一下怎么使用抓包工具跟踪啊,写web service基本还是新手[:)]
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
685
import
I
后退
顶部