为什么使用HTTPS时axis2客户端提示"An unknown transport called https exists."?

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

在 HTTP 中使用我的 axis 客户端时,我的代码工作正常,但是一旦我使用 HTTPS 端点,我就会得到以下堆栈跟踪

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

这是 HTTP 客户端配置

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);

这是我在打电话之前使用的代码

// 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();

关于这个的文档不多,有没有人看到我在这里做错了什么?

默认情况下,axis2 配置中没有 HTTPS 的描述符。您通常可以通过代码更改它,但由于某种原因,我的版本无法正常工作。您可以做的是将位于 JAR 中的 axis2 vanilla 版本复制到您的 Maven 存储库中,您可以使用 7zip 打开它。然后在你的代码中,在创建上下文的时候,指定配置文件的路径:

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

在您的配置中,将 Transport Outs 部分替换为以下内容

<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>

您可以在 SAP website

上找到

完成此配置后,axis2 应该能够找到 HTTPS 描述符并且错误应该消失。

这是我用过的完整配置,我在axis2版本1.5.4

Axis2 full configuration for HTTPS support on multi-threading mode