小编Leo*_*rdo的帖子

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());
Run Code Online (Sandbox Code Playgroud)

现在的代码是

        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());
Run Code Online (Sandbox Code Playgroud)

java httpclient apache-axis

4
推荐指数
1
解决办法
7134
查看次数

标签 统计

apache-axis ×1

httpclient ×1

java ×1