我想通过调用一个URL来开始我的路由。我的启动路线还没有准备好,但是运行得很好。我的问题是,当我使用rest-route (调用start-route )时,我会收到一条错误消息。
public class MyRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration().component("restlet")
.host("localhost").port("8080");
rest()
.get()
.route()
.to("direct:start");
from("direct:start")
.setHeader(HTTP_METHOD, constant("GET"))
.to("http4://{host}:{port}/api/v2/data/adapter?authUsername=username&authPassword=pw&authenticationPreemptive=true")
.process(Utils.javascript("converter.js"))
.enrich("direct:add", new MyAggregationStrategy())
//Mapping der JSON zur XML-Konfiguration
//.to("file:E:\\ApacheServiceMix\\apache-servicemix-7.0.1\\deploy")
.to("file:C:\\Users\\dwiesemann\\Desktop\\myTestOrdner")
.log("${body}");
from("direct:add")
.setHeader(HTTP_METHOD, constant("GET"))
.to("http4://{host}:{port}/api/v2/data/application?authUsername=username&authPassword=pw&authenticationPreemptive=true")
.process(Utils.javascript("converter.js"));
}
}我可以启动这个程序,没有任何错误。调用URL (http://localhost:8080/?restletMethods=GET)时出现错误。但是,只有当对api (我从中检索JSON)的请求在启动路由中时,才会出现错误。当我注释掉这两行时,一切都正常工作,并且没有收到任何错误消息。否则会弹出以下错误消息:
Jul 23, 2019 3:31:38 PM org.restlet.engine.connector.NetServerHelper$1 rejectedExecution
WARNUNG: Unable to run the following server-side task: sun.net.httpserver.ServerImpl$Exchange@327acd17发布于 2019-07-24 16:00:23
代码现在可以工作了。我必须将" to“改为"toD”,并设置"bridgeEndpoint=true“(在URL中),这样HttpProducer就会忽略报头。
public class MyRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration().component("restlet")
.host("localhost").port("8080");
rest()
.get()
.route()
.to("direct:start");
from("direct:start")
.toD("http4://{host}:{port}/api/v2/data/adapter?authUsername=username&authPassword=pw&authenticationPreemptive=true&bridgeEndpoint=true")
.process(Utils.javascript("converter.js"))
.enrich("direct:add", new MyAggregationStrategy())
//Mapping der JSON zur XML-Konfiguration
//.to("file:E:\\ApacheServiceMix\\apache-servicemix-7.0.1\\deploy")
.setHeader(Exchange.FILE_NAME, constant("testDok.json"))
.to("file:C:\\Users\\dwiesemann\\Desktop\\myTestOrdner")
.log("${body}");
from("direct:add")
.toD("http4://{host}:{port}/api/v2/data/application?authUsername=username&authPassword=pw&authenticationPreemptive=true&bridgeEndpoint=true")
.process(Utils.javascript("converter.js"));
}
}https://stackoverflow.com/questions/57165975
复制相似问题