camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Avnish Pundir <avnish.pun...@tekmindz.com>
Subject Re: apache camel returns statusCode:500
Date Tue, 18 Oct 2016 15:17:19 GMT
Looks like your web-service is expecting special headers (either content 
type or something alike), you can try setting the content type and also 
set the request type to POST explicitly (in one of the peculiar use case 
I had to use it explicitly) using following code:

.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.setHeader(Exchange.CONTENT_TYPE, constant("application/json"))

I'll still recommend that you either look into your server logs to find 
out exact root cause or enable the TRACE logging for apache http package 
(assuming you are using http or http4 component) to see what's going on 
the wire, compare it what postman is sending and adapt your route 
accordingly.

Thanks,
Avnish Pundir



On 18-10-2016 07:06, meng wrote:
> Hi All,
> I'm the new of camel. I now use apache camel to call several our
> webservices.
>
> Here is my code:
> public void configure() throws Exception{
>             from("direct:start")
>                     .marshal()
>                     .string(UTF_8)
>                     .to(TARGET http)
>                     .process(new Processor() {
>                         @Override
>                         public void process(Exchange exchange) throws
> Exception {
>                             String message =
> exchange.getIn().getBody(String.class);
>                             System.out.println(message);
>                         }
>                     })
>                    .to("stream:out");
>
> I'm sure there is no problem about the target endpoint, for I can get
> correct response using postman.
> But camel give me 500 error.
> Caused by: org.apache.camel.http.common.HttpOperationFailedException: HTTP
> operation failed invoking http://.... with statusCode: 500
> 	at
> org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:240)
> ~[camel-http-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:162)
> ~[camel-http-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:238)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	at
> org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132)
> ~[camel-core-2.16.1.jar:2.16.1]
> 	... 16 common frames omitted
>
> Could you help what's my problem or how can I debug it?
> Thanks a lot!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/apache-camel-returns-statusCode-500-tp5788888.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


-- 
 
------------------------------
Disclaimer: The information contained in this communication is 
confidential, private, proprietary, or otherwise privileged and is intended 
only for the use of the addressee.Unauthorized use, disclosure, 
distribution or copying is strictly prohibited and may be unlawful. If you 
have received this communication in error, please delete this message and 
notify the sender immediately - Samin TekMindz India Pvt.Ltd. 
------------------------------

Mime
View raw message