2016-02-29 4 views
1

После простого верблюда отдыха-DSLCamel запрос остальное-DSL возвращает 404

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:camel="http://camel.apache.org/schema/spring" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> 


<camelContext xmlns="http://camel.apache.org/schema/spring"> 
    <restConfiguration bindingMode="auto" component="netty4-http" port="8080" host="localhost"/> 
    <rest path="/mycontext"> 
     <get uri="/foo"> 
      <to uri="direct:fooService"/> 
     </get> 
    </rest> 

    <route> 
     <from uri="direct:fooService"/> 
     <to uri="netty4-http:http://localhost:9773/services/foo"/> 
    </route> 

</camelContext> 

, когда я призываю curl localhost:8080/mycontext/foo он всегда возвращает 404 со следующими исключениями:

org.apache.camel.component.netty4.http.NettyHttpOperationFailedException: Netty HTTP operation failed invoking http://localhost:9773/services/foo with statusCode: 404 
at org.apache.camel.component.netty4.http.NettyHttpHelper.populateNettyHttpOperationFailedException(NettyHttpHelper.java:160) 
at org.apache.camel.component.netty4.http.NettyHttpProducer$NettyHttpProducerCallback.done(NettyHttpProducer.java:111) 
at org.apache.camel.component.netty4.NettyProducer$NettyProducerCallback.done(NettyProducer.java:491) 
at org.apache.camel.component.netty4.handlers.ClientChannelHandler.channelRead0(ClientChannelHandler.java:189) 
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) 

Когда я взял захват пакета, я вижу, что строка запроса неверна

GET http://localhost:9773/services/foo HTTP/1.1 

но когда я ударил фоновым непосредственно запрос линия GET /services/foo HTTP/1.1

Может кто-то пожалуйста, помогите мне выяснить этот вопрос

+0

Вы можете попытаться настроить URI для вызова в заголовке 'Exchange.HTTP_URI' заранее или попытаться установить' & bridgeEndpoint = true' в качестве свойства. Как [documented] (http://camel.apache.org/netty4-http.html) Camel удалит все свойства компонента перед вызовом фактического URI. Не уверен, хотя, если это решает вашу проблему –

+0

, к сожалению, проблемы все равно выходят :( – user392919

ответ

0

Ваш код не является правильным.

<to uri="netty4-http:http://localhost:9773/services/foo"/> 

Компонент netty, упомянутый в документации, касается связи TCP/UDP, а не HTTP. В любом случае URI также является неправильным.

Вы можете, например, написать для TCP:

<from uri="netty4:tcp://localhost:5022?textline=true&amp;sync=true&amp;workerPool=#sharedPool&amp;usingExecutorService=false"/> 
    <to uri="log:result"/> 

Посмотрите http://camel.apache.org/netty4.html для объяснения по этому вопросу. Если вы хотите использовать HTTP-связь, используйте причал или Restlet.

Смежные вопросы