camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GLD <>
Subject RE: How to process the response in Camel
Date Fri, 07 Nov 2008 11:34:36 GMT


Claus Ibsen wrote:
> Hi
> Ah that is a little pitfall with the producerTemplate as it has many
> methods.
> You should use sendXXX for IN only message exchange patterns
> You should use requestXXX for IN-OUT message exchange patterns
> So you should use requestBody:
>         result = camelProducerTemplate.requestBodyAndHeaders(endPointUri,
> httpBodyString, exchangeMapHeaders);

The only method requestXXX that exist is with a single hearder (no s at the
end of the method)
   Object requestBodyAndHeader(String endpointUri, Object body, String
header, Object headerValue);

And I want to add all http headers in order to rebuild the same http request
to my "european server".

requestBodyAndHeader calls sendBodyAndHeader. For sendXXX, there are 
   Object sendBodyAndHeader(String endpoint, 
                                         ExchangePattern pattern, 
                                         final Object body, 
                                         final String header,
    Object sendBodyAndHeaders(String endpointUri, 
                                           final Object body, 
                                           final Map<String, Object>
Using the problem using sendBodyAndHeaders is I cannot set  the
ExchangePattern to InOut.
Your are right, running in debug mode, I see that the exchange pattern
associated to the endpoint is InOnly.
  ==> Is there a way to specify the Exchange pattern in another way (via the
endpoint uri like dataformat?,  pring property)

But I don't know if the problem is here. In my servlet, I am able to process
the Exchange;
getOut() and put it in the httpResponse.getOutputStream() 

            result = camelProducerTemplate.sendBodyAndHeaders(endPointUri,
            InputStream isResult = (InputStream)result;
            final OutputStream respOs;
            respOs = httpResponse.getOutputStream();  

            while (isResult.available() != 0) {
                final int readByte =;

My Problem is that, in that case, I cannot process the response stream. In
my example, the client will receive prices in euros instead of in dollars.

So, I think my problem is to insert a processor to process the reply.!!!

Claus Ibsen wrote:
> What is the content on endPointUri? Do you send it the direct or the http
> endpoint?
endPointUri is tha string that contains "direct:myServletServiceUri"

Guilaume Lundy

Med venlig hilsen
Claus Ibsen
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576

-----Original Message-----
From: GLD [] 
Sent: 7. november 2008 11:28
Subject: How to process the response in Camel

Hi all, 

I want to make a  Camel base engine that adapts web services requests and
For example : 
- convert currencies from dollars to euro in both requests and responses
- The client understands Dollars
- The server understands euros.
I have the following route
<endpoint id="httpEndpointBackend"
  <from uri="direct:myServletServiceUri" />   <!-- called by a servlet doGt
and doPost methods-->
  <process ref="myProcessor" />
  <to ref="httpEndpointBackend" />
In my servlet, I extract http  headers and body, send them to by endpoint
        result = camelProducerTemplate.sendBodyAndHeaders(endPointUri,
httpBodyString, exchangeMapHeaders);

With this configuration, I can successfully process the request but I cannot
process the response.
I think it because processors are asynchonous  but my  process is

Is there a way to  either
 - use processors in a synchronous way (like servlet filters chain) 
 - define a processor that will be called once the http endpoint receives
its http response


View this message in context:
Sent from the Camel - Users mailing list archive at

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message