Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Getting Bad Request response invoking REST web service

$
0
0
Hi,
I am trying to invoke an online REST web service through my Camel route and
get an http Bad Request response. I am not able to understand what is going
wrong.

This is the code snippet for my route:-
MethodCallExpression encodingTransformer = new
MethodCallExpression(URLEncoderTransformer.class, "transformBody");

from(documentServiceEndpoint)
.unmarshal(format)
.transform(encodingTransformer)
.setHeader(Exchange.HTTP_URI,
simple("http://www.thomas-bayer.com/sqlrest/CUSTOMER/18/"))
.toF("http://url")
.process(new Processor() {
@Override
public void process(Exchange exchange) {
Object fileNetResponse = exchange.getIn().getBody();

} //End process
})

It fails on the invocation of the REST web service itself. I am not sure
what is the best way to invoke the service.

My Java snippet to invoke the same snippet works fine:-
URL testUrl = new URL("http://www.thomas-bayer.com/sqlrest/CUSTOMER/18/");
URLConnection conn = testUrl.openConnection();
BufferedReader in = new BufferedReader(new
InputStreamReader(conn.getInputStream()));

String inputLine = null;

while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);

in.close();

Can someone please help me understand how I can do the same thing above in
Java in Camel?

Viewing all articles
Browse latest Browse all 5648

Trending Articles