I'm using the Java DSL to do something akin to the following:

from("xxx")
        .setBody("<root><p>Hi</p></root>")
        .recipientList(method(MyBean.class, "myMethod"))
.end()

MyBean's myMethod() method is intended to calculate the HTTP endpoint to
call:

public String myMethod(
        @Body String body, 
        @Headers Map<String, Object> inHeaders,
        @OutHeaders Map<String, Object> outHeaders,
        Exchange exchange
) {
        outHeaders = inHeaders;

        outHeaders.put(Exchange.HTTP_METHOD, "GET");
        exchange.getIn().setBody(null);

        return "http://somewebservice.com";;
}

The problem is because the body of the Exchange's In Message going into the
recipient list method is not null, an InvalidPayloadException is therefore
thrown.

Setting the body within the method has no effect because it seems the
component used by the method's return value is passed the pre-recipient list
method's body.

What I'm doing now is using two methods, one pre-recipientList method to
calculate/set the headers etc., and the recipientList's method itself just
returns the HTTP string now. 

What better ways are there of doing this? It would be nice to solve it with
one method. Use the HTTP component class directly?

Thanks, R

--
View this message in context: 
http://camel.465427.n5.nabble.com/RecipientList-with-bean-method-to-set-HTTP-endpoint-string-tp5715771.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to