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

问题描述 投票:0回答:1

我试图使用https4组件打https服务器我想得到任何响应服务器抛出它可能成功或失败这里是我的路线。

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]”,“缺少以下必需参数:[IN] [uploadAndImportFile.fileTypeEnumId] “],” removePathAlias “:假” 的loggedIn “:真正的” USERNAME “:” 管理”, “_ _ LOGIN_PASSED”: “TRUE”, “webSiteId”: “API”}

这就是我想从骆驼中得到的

apache http-headers apache-camel dsl
1个回答
0
投票

在对org.apache.camel.http4中已经清楚地提到我的解决方案之后,随机简要浏览了骆驼异常。

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

from("direct:start")....to("https4://.......?throwExceptionOnFailure=false")
© www.soinside.com 2019 - 2024. All rights reserved.