AXIS2 设置超时时间无效!!!!!
有使用过AXIS2 的大大么?
使用这个动态调用webservice时,由于数据量大,不能再默认的超时时间1分钟内读取完,然后把时间设置为10分钟,发现设置无效,依然是超过1分钟就超时。
求解!!!!
代码:
private String invokeSAPItf(List<Map<String,Object>> params,WSItfInfoVO wsinfo) throws BusinessException { ObjectMapper om = new ObjectMapper(); String jsonstr = null; try { om.configure(com.fasterxml.jackson.core.JsonGenerator.Feature.QUOTE_FIELD_NAMES, false); //json 字段名去掉引号 jsonstr = om.writeValueAsString(params); logger.debug("invoke sap param: " + jsonstr); } catch (JsonProcessingException e) { logger.error("调用SAP接口,转换参数出错!", e); throw new BusinessException("调用SAP接口失败",e); } try { ServiceClient sc = new ServiceClient(); Options o = sc.getOptions(); o.setTo(new EndpointReference(wsinfo.getUrl())); o.setAction(wsinfo.getAction()); o.setTimeOutInMilliSeconds(10*60*1000L); // 超时时间 10 分钟 sc.setOptions(o); OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNS = fac.createOMNamespace(wsinfo.getNs(),"ns0"); OMElement method = fac.createOMElement(wsinfo.getMethod(), omNS); OMElement value = fac.createOMElement(new QName(wsinfo.getParamname())); value.setText(jsonstr); method.addChild(value); OMElement retOM = sc.sendReceive(method); // 处理返回值 String result = retOM.getFirstElement().getText(); logger.debug("invoke sap result: " + result); return result; } catch (AxisFault e) { logger.error("调用SAP接口失败!", e); throw new BusinessException("调用SAP接口失败",e); } }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决,找了好久,基本都是以讹传讹的设置 setTimeOutInMilliSeconds,这个根本不管用。
只有一篇博客的方法是正确的。
正确的配置应该是:
o.setProperty(org.apache.axis2.transport.http.HTTPConstants.SO_TIMEOUT,new Integer(600000));
o.setProperty(org.apache.axis2.transport.http.HTTPConstants.CONNECTION_TIMEOUT,new Integer(600000));
http://blog.mchz.com.cn/?p=804,这个博客的链接已经失效了,内容在百度快照里找到的。