似乎 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());