有使用过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);
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
解决,找了好久,基本都是以讹传讹的设置 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,这个博客的链接已经失效了,内容在百度快照里找到的。