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_关于null,nil

Delphi 关于动态数组指针操作的两个例子

Delphi 新建文件夹函数

Delphi 启动程序隐藏主窗体

Delphi 磁盘类型 getdrivetype

Delphi 释放资源文件

Delphi写的简单的文件的打开和关闭

Delphi unigui中如何监听session的开始与结束

Delphi创建证书密钥库文件

Delphi的tfilestream 内存流

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



打赏

取消

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

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

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

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

评论

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

    正在狠努力加载,请稍候...