如何在 apache camel DSL 中获得正确的 https 服务器响应?

How to get proper https server response in apache camel DSL?

我正在尝试使用 https4[访问 https 服务器 组件 我想得到服务器抛出的任何响应可能 successfailed这是我的路线。

from("direct:start")
   .setHeader(Exchange.HTTP_QUERY,constant("USERNAME=__&PASSWORD=__"))
   .to("https4://someAddress.com/api/controls/uploadAndImportFileFromCSV")
   .to("stream:out");

我得到的输出:

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-rajat-Lenovo-G50-70-1513247400372-0-1]
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1847)
.........
Caused by: org.apache.camel.http.common.HttpOperationFailedException: HTTP operation failed invoking https4://someAddress.com/api/controls/uploadAndImportFileFromCSV?USERNAME=__&PASSWORD=__ with statusCode: 599

但是每当我在网络浏览器上点击这个URL时,我都会得到服务器抛出的准确响应

喜欢 {"sessionId":"2985416A1F1122694031261B55F0277F.jvm1",""_ERROR_MESSAGE_LIST_":[" 缺少以下必需参数: [IN]uploadAndImportFile.configId]","The following required parameter is missing: [IN][uploadAndImportFile.fileTypeEnumId]"],"removePathAlias":假,"loggedIn":真,"USERNAME":"admin",“_LOGIN_PASSED_”:"TRUE","webSiteId":"API"}

这就是我想从骆驼那里得到的

在随机浏览了 camel exception 之后,我得到了我的解决方案已经在 org.apache.camel.http4.

上清楚地提到了

如果throwExceptionOnFailure=false HttpOperationFailedException 将不会为失败的响应代码抛出。这允许您从远程服务器获得任何响应。

from("direct:start")....to("https4://.......?throwExceptionOnFailure=false")