3

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

1 回答 1

4

您可以使用HttpMethodParams.RETRY_HANDLER参数进行设置。在你的情况下,例如:

HttpMethodParams methodParams = new HttpMethodParams();
DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(0, false);
methodParams.setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
opts.setProperty(HTTPConstants.HTTP_METHOD_PARAMS, methodParams);

wso2.org 网站上有一个主题。

于 2010-02-06T14:25:27.330 回答