天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

 找回密码
 注册成为天翎用户
查看: 3086|回复: 0

[整合] 调用webservice接口查询文档的记录

[复制链接]
irene 发表于 2012-4-18 14:47:38 | 显示全部楼层 |阅读模式
本帖最后由 irene 于 2012-8-15 10:23 编辑

Q:怎么调用webservice接口查询文档的记录,该用哪个方法?
A:可参考如下脚本
  1.         public static void main(String[] args) throws DocumentServiceFault, RemoteException{
  2.                 // TODO Auto-generated method stub
  3.                 DocumentServiceServiceLocator locator = new DocumentServiceServiceLocator();
  4.                 java.net.URL url;
  5.                 try{
  6.                         url = new java.net.URL("http://127.0.0.1:8080/obpm/services/DocumentService?wsdl");//wsdl文件的目录
  7.                         DocumentService service = locator.getDocumentService(url);
  8.                         String formName = "分支流程";//表单的名称
  9.                         String domainUserId = "11de-c13a-0cf76f8b-a3db-1bc87eaaad4c";//用户ID,存在类似于tlk_分支流程表的AUTHOR字段里
  10.                         HashMap parameters = new HashMap();//目前parameters参数没有起到实际作用,所以用任意参数查出的都是全部的记录。
  11.                         String applicationId = "11de-ef9e-c010eee1-860c-e1cadb714510";//applicationId,软件的应用id
  12.                         Object[] obj = service.searchDocumentsByFilter(formName, parameters, applicationId, domainUserId);
  13.                         int len = obj.length;
  14.                         for(int i = 0;i<len;i++){
  15.                                 SimpleDocument s=(SimpleDocument)obj[i];
  16.                                 String sid = s.getId();//获取表单记录ID
  17.                                 HashMap hm =new HashMap();
  18.                                 hm=s.getItems(); //获取动态表单item_开头的字段的map集合
  19.                                 Iterator   it   =hm.keySet().iterator();
  20.                                 while(it.hasNext())
  21.                                 {                         
  22.                                   String   key   =   (String)it.next();   //   获取HashMap中的key值
  23.                                   System.out.println(key+"取值:"+hm.get(key));//获取HashMap中key对应的值
  24.                                 }
  25.                         }
  26.                 }catch(MalformedURLException e){
  27.                         e.printStackTrace();
  28.                 } catch (ServiceException e) {
  29.                         // TODO Auto-generated catch block
  30.                         e.printStackTrace();
  31.                 }

  32.         }
复制代码
PS:如果用.net语言调用webservice,不可使用HashMap parameters = new HashMap();,因为.net不支持HashMap,需用Map parameters = new Map();

本版积分规则

QQ|手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-12 12:35

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表