sothach wrote
> I need to integrate with a third party system via its WS interface.  To
> send a request, I must first "login" to the server, and obtain an
> authentication token to attach to all subsequent requests.  This token has
> a limited shelf-life, and will time-out after a period of time, requiring
> me to re-apply.
> My question: is there a standard pattern in Camel for this scenario? 
> My first thought is to implement this by having an enrichment stage, that
> calls out to "direct:login" route, setting a header with the token, that
> can then be used when marshaling the call.  
> Is there a simpler way?

I am new to camel, but am facing the same problem and have chosen to use the
enrichment pattern, mostly because I need to implement other, more
"classical" enrichment scenarios. Interceptors are an alternative approach,
but I think are not simpler, especially given the timeout and refresh
requirements.

Two "bits" of information that may be helpful to you. 

The Enrich(er) resource is expected to implement the Producer interface.
This may be obvious to an experienced Cameler, but I didn't see it
documented and only discovered reading  the Enricher source.
<http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Enricher.java?view=markup>
  
The Enricher only exercises the process method of the Processor
super-interface, however, not Service start and stop, at least in my
configuration. I use a ProducerTemplate instance within the Producer
implementation that is configured with the same endpoint as the regular
messages.

This will not apply to you unless you use CXF messages in Pojo data format
and "out-of-band" SOAP headers to send the authentication token, but the
example code in 
http://camel.apache.org/cxf.html#CXF-HowtogetandsetSOAPheadersinPOJOmode
<http://camel.apache.org/cxf.html#CXF-HowtogetandsetSOAPheadersinPOJOmode>  
is broken. If there are no existing headers, the example
InsertResponseOutHeaderProcessor.process will throw a NullPointerException,
mistakenly trying to use the QName from an existing header to create the new
one.

I've been meaning to post an issue about this, but there it is....

Otherwise, the Enrich is working well for me inside a basic proxy based on
the camel examples, with routing based on the SOAP action/operation.





--
View this message in context: 
http://camel.465427.n5.nabble.com/Login-session-token-with-Camel-CXF-tp5728467p5728477.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to