AXIS2如何设置连接重试?
看来 Axis 管理客户端 org.apache.axis2.client.ServiceClient 正在发出 org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry() 和 默认重试3次。有没有办法设置不重试?
我的代码:
ServiceClient client = new ServiceClient();
Options opts = new Options();
opts.setTo(new EndpointReference(strWebServiceUrl));
opts.setAction(strNameOfMethodToInvoke);
opts.setTimeOutInMilliSeconds(timeOut);
client.setOptions(opts);
OMElement res = client.sendReceive(createRequest());
return (res.toString());
现在的代码是
ServiceClient client = new ServiceClient();
Options opts = new Options();
opts.setTo(new EndpointReference(strWebServiceUrl));
opts.setAction("urn:" + strNameOfMethodToInvoke);
opts.setTimeOutInMilliSeconds(timeOut);
HttpMethodParams methodParams = new HttpMethodParams();
DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(0, false);
methodParams.setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
opts.setProperty(HTTPConstants.HTTP_METHOD_PARAMS, methodParams);
client.setOptions(opts);
OMElement res = client.sendReceive(createRequest());
return (res.toString());
It seems that the Axis admin client org.apache.axis2.client.ServiceClient
is issuing org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry() and
the retry is like 3 times by default. Is there a way to set to not do retries?
My code:
ServiceClient client = new ServiceClient();
Options opts = new Options();
opts.setTo(new EndpointReference(strWebServiceUrl));
opts.setAction(strNameOfMethodToInvoke);
opts.setTimeOutInMilliSeconds(timeOut);
client.setOptions(opts);
OMElement res = client.sendReceive(createRequest());
return (res.toString());
The code now is
ServiceClient client = new ServiceClient();
Options opts = new Options();
opts.setTo(new EndpointReference(strWebServiceUrl));
opts.setAction("urn:" + strNameOfMethodToInvoke);
opts.setTimeOutInMilliSeconds(timeOut);
HttpMethodParams methodParams = new HttpMethodParams();
DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(0, false);
methodParams.setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
opts.setProperty(HTTPConstants.HTTP_METHOD_PARAMS, methodParams);
client.setOptions(opts);
OMElement res = client.sendReceive(createRequest());
return (res.toString());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
HttpMethodParams.RETRY_HANDLER
参数进行设置。例如,在您的情况下:wso2.org 网站 上有一个线程。
You can set it using the
HttpMethodParams.RETRY_HANDLER
parameter. In you case, for example:There is a thread on the wso2.org website.