camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "praneeth.purighalla" <>
Subject Using cxfrs producer with a dynamic endpoint from a metadata file
Date Mon, 15 Jun 2015 03:35:28 GMT
Hi All,

I'm completely new to Camel. So please bear with this requirement of mine.
I have a file that contains some metadata in XML. This metadata includes the
URI of my external HTTP service along with authentication details to connect
to the endpoint. I'm trying to build my camel route in such a way that I
read the metadata file, retrieve all the relevant details like URI,
username, password, etc and then invoke the URI.

This is my routing code:

    	.setProperty("username", xpath("/endpoint/authentication/username",
    	.setProperty("password", xpath("/endpoint/authentication/password",
    	.setProperty("uri", xpath("/endpoint/uri", String.class))
    	.process(new Processor() {

			public void process(Exchange exchange) throws Exception {
				// set exchange pattern as InOut
				Message inMessage = exchange.getIn();
				// using the http central client API
		        // set the Http method
		        inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
		        // set authorization header
		        String username = exchange.getProperty("username", String.class);
		        String password = exchange.getProperty("password", String.class);
		        inMessage.setHeader("Authorization", "Basic " +
base64Encode(username + ":" + password));
		        CxfRsEndpoint myCxfEp = (CxfRsEndpoint)
getContext().getEndpoint(exchange.getProperty("uri", String.class));

		        ProducerTemplate template = getContext().createProducerTemplate();
		        Exchange response = template.send(myCxfEp, exchange);

			private String base64Encode(String input) {
				return Base64Utility.encode(input.getBytes());


I want to capture the response from the external HTTP service into a file.
When I sniff the request using TCPMON, I can see the expected request and
response. However, the exchange object that gets written to the outbox in my
final route node is still the metadata file in my "from" endpoint.

Can someone help me with this? Am I doing something wrong or is there a
better/easier way to achieve this?

Here is a snippet of my metadata file:


Thanks in advance,

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

View raw message