Azh*_*l A 13 java apache-camel
我已经编写了使用apache camel调用rest api的示例代码.哪个在独立工作正常,但是我用来创建OSGI捆绑包的相同代码并将其部署到karaf容器中,捆绑包是成功创建的但我得到的错误如"没有组件找到方案http"当我尝试叫它.
你能帮我解决这个问题吗?
这是代码:
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start")
.setHeader(Exchange.HTTP_METHOD,simple("GET"))
.to("http://10.10.10.10:8080/RestfulDemo/rest/get");
}
});
context.start();
ProducerTemplate template = context.createProducerTemplate();
String headerValue = "application/xml";
Map<String, Object> headers = new HashMap<String,Object>();
headers.put("Content-Type", headerValue);
Object result = template.requestBodyAndHeaders("direct:start", null, headers, String.class);
Exchange exchange = new DefaultExchange(context);
String response = ExchangeHelper.convertToType(exchange, String.class, result);
System.out.println("Response : "+response);
context.stop();
Run Code Online (Sandbox Code Playgroud)
错误如下:
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: http://10.10.10.10:8080/RestfulDemo/rest/get due to: No component found with scheme: http
Run Code Online (Sandbox Code Playgroud)
Pet*_*ler 16
将以下snipplet添加到您的pom.xml:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
Run Code Online (Sandbox Code Playgroud)
如果您在OSGI/Karaf/ServiceMix/JBoss FUSE ESB环境中使用Camel,则必须通过Karaf控制台添加捆绑包
features:install camel-http
Run Code Online (Sandbox Code Playgroud)
有关安装camel for Karaf的更多信息,请访问http://camel.apache.org/karaf
| 归档时间: |
|
| 查看次数: |
23502 次 |
| 最近记录: |