camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Gargan <steve.gar...@gmail.com>
Subject Re: ActiveMQ - Camel as client POST?
Date Thu, 07 Jan 2010 00:35:32 GMT
No the JsonDataFormat does not set the content type you'll need to do
that yourself. Try specifying the content type explicitly

from("direct:simple-http-send").marshal().json().setHeader(Exchange.CONTENT_TYPE,
constant("application/json")).to("http://host:port/service")

use what ever mime type your service is expecting.

There is more info here....

http://camel.apache.org/http.html

Give this a shot.

ste


On Wed, Jan 6, 2010 at 4:09 PM, user09772 <sonnyheer@gmail.com> wrote:
>
> I had the xstream depend. missing.
>
> Although I'm unable to POST to a simple Jersey service.
>
> Doing this in the camel config:
> from("direct:simple-http-send").marshal().json().to("http://host:port/service");
>
> In the consumer:
> ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
> producerTemplate.sendBody("direct:simple-http-send", sendObj);
>
>
> Getting the following exception now:
>
> Caused by: org.apache.camel.component.http.HttpOperationFailedException:
> HTTP operation failed invoking http://host:port/service with statusCode: 415
>        at
> org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:150)
>        at
> org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:92)
>        at
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
>        at
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95)
>        at
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
>        at
> org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
>        at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at
> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>        at
> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>        at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:223)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:153)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
>        at
> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:206)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
>        at
> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
>        at
> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:45)
>        at
> org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:179)
>        at
> org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:161)
>        at
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
>        at
> org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:160)
>        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:98)
>        at
> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:97)
>        at
> org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:110)
>        ... 27 more
>
>
>
>
>
>
> This would happen if i didn't indicate a content-type, but I'm assuming
> marshal().json()  would do this for me.  Any Ideas?
>
> Thanks.
> --
> View this message in context: http://old.nabble.com/ActiveMQ---Camel-as-client-POST--tp26896366p27026992.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message