Hi there,

I have to read data from a remote host with the http component. The provider of 
that remote host had sent to me a security token that I have to embed as a 
query parameter into the request. Of course, I don't want to write that 
security token into my program, nor do I want to write it in a properties file. 
So I read a little bit about Jasyp in Camel and the Camel Properties component. 
All very nice. I must use the header Exchange.HTTP_QUERY because I have to 
provide proxy informations into the http request.

So, a working example looks like this:
from ("direct:startToRead")
.routeId("startToRead")
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.setHeader(Exchange.HTTP_QUERY, constant(
"securityToken={{token}}"
+ "&start=201612312300"
+ "&end=201701312300"))
.log("start to read")
.toD("${body}")

The encrypted token is written in a properties file, and it is resolved as 
desired.

As you can see, the request also contains a start and an end timestamp. These 
timestamps have to be calculated dynamically before. When I try to do so, the 
http request is garbled because the {{token}} part is not resolved. This is the 
error message:
org.apache.camel.http.common.HttpOperationFailedException: HTTP operation 
failed invoking 
http://the.remote.host?securityToken=%7B%7Btoken%7D%7D&periodStart=201612312300&periodEnd=201701312300
 with statusCode: 401

I tried several other ways to set this header dynamically:
  -  a Processor that sets the header Exchange.HTTP_REQUEST
  -  let the Processor write it into a custom header and use its value in an 
invocation of .setHeader
  -  let a Provider construct the String

All of them failed.

Has anybody an idea how to get out of this trap? My only idea is to invoke 
Jasypt decryption in my Processor when setting up my dynamic String, but I 
don't believe that this is a good solution.

Kind regards,
Christian Jacob

Innogy SE
Retail IT
Integration and Digital Solutions (AFS-IGI)
Rellinghauser Str. 37
45128 Essen
T intern: 70-20581
T extern: +49 (0)201 12 20582
T mobil: +49 (0)1622843981
Fax: +49 (0)201 12 24796
mailto: [email protected]

----------------------------------------------------------------
innogy SE Vorsitzender des Aufsichtsrates: Dr. Werner Brandt
Vorstand: Peter Terium (Vorsitzender), Dr. Hans Buenting,
Dr. Bernhard Guenther, Martin Herrmann, Hildegard Mueller, Uwe Tigges
Sitz der Gesellschaft: Essen, Eingetragen beim Amtsgericht Essen,
Handelsregister-Nr. HRB 27091, USt-IdNr. DE304171711

Reply via email to