本文整理自网络,侵删。
JAVApojo:public class GroupInfo implements Serializable{private static final long serialVersionUID = 7646885719123155790L;private int groupId; //组idprivate 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>();elsereturn queryDao.getAllGroupInfo(policyid);}
说明:传入用户名密码,返回一个list,里面的对象是类GroupInfo的实例。
DelphiFile-->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);varI: Integer;service: res_queryPortType;arr: ArrayOfGroupInfo;beginservice := 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) dobegintrymemo1.Lines.Add(arr.groupName);exceptend;end;end;
本例在MyEclipse6.5, XFire1.2, Delphi7下测试通过。
Delphi 调用Java 写的WebSevice
无特殊要求,只要能得到wsdl,你可以先在IE里头访问一下试试。所有的字符参数全部要用widestring
相关阅读 >>
Delphi unigui中如何监听session的开始与结束
更多相关阅读请进入《Delphi》频道 >>