Why do axis2 client prompt "An unknown transport called https exists." when using HTTPS?

Viewed 336

When using my axis client in HTTP, my code works just fine, but as soon as I use an HTTPS endpoint, I get the following stack trace

Caused by: org.apache.axis2.AxisFault: An unknown transport called https exists.
    at org.apache.axis2.description.ClientUtils.inferInTransport(ClientUtils.java:119) ~[axis2-kernel.jar:1.5.4]
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:183) ~[axis2-kernel.jar:1.5.4]
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) ~[axis2-kernel.jar:1.5.4]
    at com.vodafone.gdsp.ws.SubmitSMSv2ServiceStub.submitSMSv2(SubmitSMSv2ServiceStub.java:193) ~[vodafonews.jar:?]
    at com.trilliantnetworks.vodafone.services.CallVodafoneServices.submitSMSv2(CallVodafoneServices.java:447) ~[vodafonews.jar:?]
    ... 21 more

Here's the HTTP client configuration

HttpClientParams httpClientParams = new HttpClientParams();
httpClientParams.setConnectionManagerTimeout(10000L);
HttpClient client = new HttpClient(httpClientParams, conMgr);

context.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, client);
context.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
context.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION, Boolean.TRUE);

Here's the code I'm using before making a call

// Enabling auto cleanup & activating asynchronous connection handler
serviceStub._getServiceClient().getOptions().setCallTransportCleanup(true);
serviceStub._getServiceClient().getOptions().setUseSeparateListener(true);
serviceStub._getServiceClient().engageModule("addressing");

// Executing a cleanup of the connection before using it in case.
serviceStub._getServiceClient().cleanup();
serviceStub._getServiceClient().cleanupTransport();

There is not much documentation about this, does anyone see what I'm doing wrong here?

1 Answers

By default, there's no descriptor for HTTPS in axis2 configuration. You usually can change it through the code, but for some reason, my version was not working. What you can do is copy the vanilla version of axis2 located in the JAR in your maven repositories which you can open with 7zip. Then in your code, when creating the context, specify the path of the configuration file:

ConfigurationContext context = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, "C:\\Path\\To\\Your\\Custom\\axis2.xml");

In your configuration replace the section Transport Outs by the following

<transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender" />

<transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
    <parameter name="PROTOCOL">HTTP/1.1</parameter>
    <parameter name="Transfer-Encoding">chunked</parameter>

    <!-- If following is set to 'true', optional action part of the 
         Content-Type will not be added to the SOAP 1.2 messages -->
    <!--  <parameter name="OmitSOAP12Action">true</parameter>  -->
</transportSender>

<transportSender name="https" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
    <parameter name="PROTOCOL">HTTP/1.1</parameter>
    <parameter name="Transfer-Encoding">chunked</parameter>

    <!-- If following is set to 'true', optional action part of the 
         Content-Type will not be added to the SOAP 1.2 messages -->
    <!--  <parameter name="OmitSOAP12Action">true</parameter>  -->
</transportSender>

<transportReceiver name="http" class="org.apache.axis2.transport.http.AxisServletListener">
    <parameter name="port">8080</parameter>
</transportReceiver>

<transportReceiver name="https" class="org.apache.axis2.transport.http.AxisServletListener">
    <parameter name="port">8443</parameter>
</transportReceiver>

Which you can find here on SAP website

Once this configuration is in place, axis2 should be able to find the HTTPS descriptor and the error should go away.

Here's the complete configuration I've used, I'm on axis2 version 1.5.4

Axis2 full configuration for HTTPS support on multi-threading mode

Related