AXIS2 设置超时时间无效!!!!!

发布于 2021-12-03 21:54:20 字数 1635 浏览 892 评论 1

有使用过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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花落人离去 2021-12-04 02:00:06

解决,找了好久,基本都是以讹传讹的设置 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,这个博客的链接已经失效了,内容在百度快照里找到的。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文