Apache camel 带有recipientList的动态HTTP URI在第二次调用时返回404
我有两步驼峰路由工作流-两步都对同一主机进行POST调用,但URL和正文不同。第一个调用返回第二个调用的部分URL 代码如下:Apache camel 带有recipientList的动态HTTP URI在第二次调用时返回404,apache-camel,Apache Camel,我有两步驼峰路由工作流-两步都对同一主机进行POST调用,但URL和正文不同。第一个调用返回第二个调用的部分URL 代码如下: // I register converter for different request types getContext().getTypeConverterRegistry().addTypeConverters(new RequestConverter()); from("direct:two-step-flow") .setHeader("paramId
// I register converter for different request types
getContext().getTypeConverterRegistry().addTypeConverters(new RequestConverter());
from("direct:two-step-flow")
.setHeader("paramId", body().method("getParamId")
.setHeader("url", "http://localhost:8080/api/${header.paramId}
.convertBodyTo(Step1Request.class)
.to("direct:call-remote-service")
.convertBodyTo(Step2Request.class) // converter sets newParamFromResponse
.setHeader("url", "http://localhost:8080/api/${header.paramId}/${body.newParamFromResponse}
.to("direct:call-remote-service")
.end();
from("direct:call-remote-service")
.marshal().json(JsonLibrary.Jackson)
.recipientList(header("url"))
.unmarshal().json(JsonLibrary.Jackson, GenericResponse.class)
.end();
第一步很好,HTTP流类似于
httpclient.wire.header - >> "POST /api/p1 HTTP/1.1[\r][\n]"
httpclient.wire.content - >> "{"amount":1.22,"reason":"some reason","relation-id":"12345"}"
httpclient.wire.header - << "HTTP/1.1 200 OK[\r][\n]"
httpclient.wire.header - << "HTTP/1.1 200 OK[\r][\n]"
httpclient.wire.header - << "Content-Type: application/json[\r][\n]"
httpclient.wire.header - << "Transfer-Encoding: chunked[\r][\n]"
httpclient.wire.header - << "Server: Jetty(9.3.11.v20160721)[\r][\n]"
httpclient.wire.header - << "[\r][\n]"
org.apache.camel.component.http.HttpProducer - Http responseCode: 200
我可能误用了。RecipientList,感谢您的帮助
谢谢可能是一些HTTP响应头被拾取并用于第二次呼叫。因此,请尝试删除两次调用之间的HTTP标头: 加 在使用收件人列表呼叫路线之前
可能是一些HTTP响应头被拾取并用于第二次调用。因此,请尝试删除两次调用之间的HTTP标头: 加 在使用收件人列表呼叫路线之前
没有帮助。我已经添加了问题中第一个电话的回复。没有帮助。我在问题中添加了第一个电话的回复。
httpclient.wire.header - >> "POST /api/p1/Id1 HTTP/1.1[\r][\n]"
httpclient.wire.content - >> "{"action":"CONFIRM","reason":"reason to confirm","relation-id":"12345"}"
org.apache.camel.component.http.HttpProducer - Http responseCode: 404
httpclient.wire.content - << "<html>[\n]"
httpclient.wire.content - << "<head>[\n]"
httpclient.wire.content - << "<meta http-equiv="Content-Type"
content="text/html;charset=ISO-8859-1"/>[\n]"
httpclient.wire.content - << "<title>Error 404 </title>[\n]"
httpclient.wire.content - << "</head>[\n]"
httpclient.wire.content - << "<body>[\n]"
httpclient.wire.content - << "<h2>HTTP ERROR: 404</h2>[\n]"
httpclient.wire.content - << "<p>Problem accessing /api/p1/Id1. Reason:[\n]"
httpclient.wire.content - << "<pre> Not Found</pre></p>[\n]"
httpclient.wire.content - << "<hr /><a href="http://eclipse.org /jetty">Powered by Jetty:// 9.3.11.v20160721</a><hr/>[\n]"
httpclient.wire.content - << "</body>[\n]"
httpclient.wire.content - << "</html>[\n]"
curl 'http://localhost:8080/api/p1/Id1' -i -X POST -H
'Accept:application/json' -H 'Content-Type: application/json' -d
'{
"action" : "CONFIRM",
"relation-id" : "12345",
"reason" : "reason to confirm"
}'
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(9.3.11.v20160721)
.removeHeaders("CamelHttp*")
.to("direct:call-remote-service")