Hello, I am trying some Camel with Jetty examples. The problem I have is that
after I do an http request to another site jetty no longer returns the set
body.

For example,

[code]
        from("jetty:http://localhost:8080";).setBody(constant("OK")); 
[/code]

Returns "OK" when from the browser I call the above set URL. However if the
following will not work.

[code]
        from("jetty:http://localhost:8080";)
        .to("jetty:http://www.google.com"; + 
                "?bridgeEndpoint=true" + 
                "&throwExceptionOnFailure=false")
        .setBody(constant("OK")); 
[/code]

This returns the response from google (see attachment at end of message) and
not "OK" even though after the call to google I am setting the body to "OK".

What I find strange is this ...

The following code prints in the console that the body is "OK" but the
response returned to the browser is still the response got from google.

[code]
        from("jetty:http://localhost:8080";)
        .to("jetty:http://www.google.com"; + 
                "?bridgeEndpoint=true" + 
                "&throwExceptionOnFailure=false")
        .setBody(constant("OK"))
        .log("THE BODY IS ${body}"); // This line prints "OK" in the console.
[/code]

After looking through the Jetty Camel documentation I saw an example which
was overriding the body and that one works.

[code]
        from("jetty:http://localhost:8080";)
        .to("jetty:http://www.google.com"; + 
                "?bridgeEndpoint=true" + 
                "&throwExceptionOnFailure=false")
        .process(new Processor(){
                public void process(Exchange e) throws Exception {
                        e.getOut().setBody("HELLO");
                }
        })
        // .setBody(constant("OK"))     // LINE 1
        .log("THE BODY IS ${body}");
[/code]

The above without LINE 1 remarked returns "HELLO" in both browser and
console and with LINE 1 not remarked it returns "OK" in both browser and
console.

So why does setBody work when e.getOut().setBody(...) is used but not if
this is used without the processor?


<http://camel.465427.n5.nabble.com/file/n5787905/screenshot.png> 





--
View this message in context: 
http://camel.465427.n5.nabble.com/Why-is-the-set-body-not-being-returned-tp5787905.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to