delphi调用java编写的webservice


本文整理自网络,侵删。

 

JAVA
pojo:
public class GroupInfo implements Serializable{
private static final long serialVersionUID = 7646885719123155790L;
private int groupId; //组id
private String groupName; //组名称
private int parentGroupId; //上级组id
}


方法:
public List<GroupInfo> getAllGroupInfo(String username, String password) {
IQueryDao queryDao = new QueryDaoImpl();
int policyid = queryDao.getDefaultPolicyID(username, password);
if (policyid==0)
return new ArrayList<GroupInfo>();
else
return queryDao.getAllGroupInfo(policyid);
}

说明:传入用户名密码,返回一个list,里面的对象是类GroupInfo的实例。


Delphi
File-->New-->Other-->WebServices-->WSDL Importer,
wsdl source填写http://192.168.1.174:8080/reservices/services/res_query?wsdl,确定后,自动生成了webserive的访问代码,文件名为res_query.pas

调用代码如下:
procedure TForm1.Button2Click(Sender: TObject);
var
I: Integer;
service: res_queryPortType;
arr: ArrayOfGroupInfo;
begin
service := Getres_queryPortType(true, 'http://192.168.1.174:8080/res_services/services/res_query?wsdl',nil);
arr := service.getAllGroupInfo('admin', 'admin');
memo1.Lines.Clear;
for I := 0 to Length(arr) do
begin
try
memo1.Lines.Add(arr.groupName);
except
end;
end;
end;

本例在MyEclipse6.5, XFire1.2, Delphi7下测试通过。

Delphi 调用Java 写的WebSevice

无特殊要求,只要能得到wsdl,你可以先在IE里头访问一下试试。
所有的字符参数全部要用widestring

相关阅读 >>

Delphi 打开webbrowser的选中文件路径

Delphi xe2支持zip压缩文件的操作了

Delphi读取radiogroup选中按钮的string文本

Delphi 阿拉伯数字转中文汉字数字

Delphi windows 编程[10] - wm_lbuttondown、wm_lbuttonup 和 wm_mousemove 消息

Delphi windows 编程[5] - 学习窗体生成的过程五

Delphi xe 分割字符串太方便了

Delphi xe5 将Delphi code从winos 迁移到ios与android

Delphi cxgrid中回车键光标移到下列

Delphi实现md5算法

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...