19 de noviembre de 2017

Axis2 solución a problemas!!

Solución a problemas con los clientes de Axis2:


  • Cuando se consume un servicio con HTTPS:
    • Instalar el certificado desde donde se consume el servicio
    • Saltarse el problema y no validar el certificado:

SSLContext sslCtx = SSLContext.getInstance("SSL");
sslCtx.init(null, new TrustManager[]{new TrustAllTrustManager()}, null);
            _SATStub._getServiceClient().getOptions().setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
                    new Protocol("https", (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslCtx), 443));

  • Configurar Timeout (Socket Timeout, Connection Timeout)
    • Opción uno:

Long timeout = 30L * 1000L;
        _SATStub._getServiceClient().getOptions().setTimeOutInMilliSeconds(timeout);

    • Opción dos:
Long timeout = 30L * 1000L;
_SATStub._getServiceClient().getOptions().setProperty(
                HTTPConstants.SO_TIMEOUT, timeout.intValue());

_SATStub._getServiceClient().getOptions().setProperty(
                HTTPConstants.CONNECTION_TIMEOUT, timeout.intValue());
  • Configurar los re-intentos a cero (0).
DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(0, false);
        methodParams.setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
        _SATStub._getServiceClient().getOptions().setProperty(
                HTTPConstants.HTTP_METHOD_PARAMS, methodParams);
  • Cambiar el endpoint del consumo:
_SATStub._getServiceClient().getOptions().setTo(new EndpointReference(address));



Notas y referencias: