webservice 返回documentImpl 数据为空
来源:互联网 发布:snmp trap 接收 java 编辑:程序博客网 时间:2024/06/06 12:40
在做webservice上传的时候,返回值是map对象,但是通过
Client client = new Client(new URL(surl));// client.setProperty("mtom-enabled", "true");client.setProperty(HttpTransport.CHUNKING_ENABLED, "true");Object[] results = client.invoke(saction, objarr);return results;
这种方式调用之后,结果返回的都是一个documentImpl 对象,再跟踪进去的话会发现,里面所有的都是空值,找不到正确的返回值。
我的解决办法是使用w3c的document 将取回的值强制转换,然后在根据里面的tagname获取对应的值。
代码如下,
Long start = System.currentTimeMillis();Object[] results ;long startpost = 0;int BUFFER_LENGTH = 1024 * 20;// 一次性读入大小int SLEEP_TIME = 250;// 循环读次数long filesize = 0;FileInputStream fis = null;try {File upfile = new File("d://xx.docx");filesize = upfile.length();if(filesize>5000000){System.out.println("上传文件大小不能超过5M");return; }fis = new FileInputStream(upfile);fis.skip(startpost);// 读文件前,先定位StringBuffer sb = new StringBuffer();int time = 0;byte[] buffer = new byte[BUFFER_LENGTH];int count = -1;while (time < SLEEP_TIME && (count = fis.read(buffer)) != -1) {sb.append(Base64.encode(buffer, 0, count));time++;}String ret = sb.toString();boolean uploadFlag = false;results = getWebService("http://localhost:8081/scysspjc1/webservice/WSSPWebServiceControllerPort?wsdl", "addFileContentDHS", new Object[] {"123","{AC132005-0000-0000-59D9-704F00000010}", ret }); org.w3c.dom.Document d = (org.w3c.dom.Document)results[0]; NodeList nl =d.getElementsByTagName("ns1:out"); NodeList n2 = nl.item(0).getChildNodes(); System.out.println(n2.getLength()); for (int i=0;i<n2.getLength();i++){ // System.out.println(n2.item(i).getNodeName()+"::"+n2.item(i).getTextContent()); if(n2.item(i).getTextContent().contains("STATUS")){ if(n2.item(i).getTextContent().contains("1")) uploadFlag = true; } } if(uploadFlag){ System.out.println("文件上传成功!"); }Long end = System.currentTimeMillis();System.out.println("用时:" + (end - start));} catch (FileNotFoundException e) {e.printStackTrace();throw new Exception("出错啦!", e);} catch (IOException e) {e.printStackTrace();throw new Exception("出错啦!", e);} catch (Exception e) {} finally {if(fis!=null){fis.close();}}
阅读全文
0 0
- webservice 返回documentImpl 数据为空
- Android调用webservice返回数据为空
- webservice Xfire 调用 返回值类型为map时,数据为空的问题
- android 手机拍照 返回数据为空!!!!
- 异步调用webservice返回responseXML为空的问题解决方案
- AFNetworking 返回数据为空或二进制等数据
- Struts2 返回 json 的数组数据为 "空" 的解决方案
- ArcGis Server queryTask返回数据的geometry为空
- Wininet.dll 版本引起的PostData返回数据为空
- 判断 jqGrid表格加载返回数据是否为空
- webService--返回数据集
- webService--返回数据集
- webservice返回json数据
- 服务器返回文本为空
- 为何GetProcAddress()返回为空?
- IOS pathForResource 返回为空
- findViewById 返回值为空
- DWR:返回值为空?
- python基础--空格的约定
- 安装centos6.5 时遇到acpid相关的问题:child_rip+0x0/0x20
- leetcode python 100st
- Makefile经典教程(掌握这些足够)
- ReactNative : ignoring return value of function declared with warn_unused_result attribute
- webservice 返回documentImpl 数据为空
- 支付宝手机支付接口集成总结及支付宝missing signnature config错误处理
- LCD6210字符型液晶显示器 (2)
- 3480943346903
- B-树(B树)、B+树、B*树
- Linux下logrotate命令使用.配置和理解
- bzoj 1687: [Usaco2005 Open]Navigating the City 城市交通 bfs
- web前端之过滤器的作用
- Python机器学习实践与Kaggle实战