本帖最后由 irene 于 2012-8-15 10:23 编辑
Q:怎么调用webservice接口查询文档的记录,该用哪个方法?
A:可参考如下脚本- public static void main(String[] args) throws DocumentServiceFault, RemoteException{
- // TODO Auto-generated method stub
- DocumentServiceServiceLocator locator = new DocumentServiceServiceLocator();
- java.net.URL url;
- try{
- url = new java.net.URL("http://127.0.0.1:8080/obpm/services/DocumentService?wsdl");//wsdl文件的目录
- DocumentService service = locator.getDocumentService(url);
- String formName = "分支流程";//表单的名称
- String domainUserId = "11de-c13a-0cf76f8b-a3db-1bc87eaaad4c";//用户ID,存在类似于tlk_分支流程表的AUTHOR字段里
- HashMap parameters = new HashMap();//目前parameters参数没有起到实际作用,所以用任意参数查出的都是全部的记录。
- String applicationId = "11de-ef9e-c010eee1-860c-e1cadb714510";//applicationId,软件的应用id
- Object[] obj = service.searchDocumentsByFilter(formName, parameters, applicationId, domainUserId);
- int len = obj.length;
- for(int i = 0;i<len;i++){
- SimpleDocument s=(SimpleDocument)obj[i];
- String sid = s.getId();//获取表单记录ID
- HashMap hm =new HashMap();
- hm=s.getItems(); //获取动态表单item_开头的字段的map集合
- Iterator it =hm.keySet().iterator();
- while(it.hasNext())
- {
- String key = (String)it.next(); // 获取HashMap中的key值
- System.out.println(key+"取值:"+hm.get(key));//获取HashMap中key对应的值
- }
- }
- }catch(MalformedURLException e){
- e.printStackTrace();
- } catch (ServiceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
复制代码 PS:如果用.net语言调用webservice,不可使用HashMap parameters = new HashMap();,因为.net不支持HashMap,需用Map parameters = new Map(); |