XPATH Select based on message header value

Posted by sedge on 14-Feb-2011 21:05

I have an XPATH expression in a Request Mapping that selects an element based on an Attrubute value:

     /rcbi:ini/rcbi:Message/rcbi:Parameters[@Env='PRD']

Rather than a hard coded value I want to perform the selection based on the value of a Message Header:

     ${esbmsg.headers['Environment']}

Is it possible to code the XPATH to perform the selection based on the "Environment" header? (I can easily move the value to be a Message part if that is preferable).

Thanks

Steve

All Replies

Posted by mnair on 16-Feb-2011 10:58

Hi Steve,

EL expressions are currently not supported in the XPath expression in message mapping. I will log an enhancement request for this.

Thanks

-Mahesh

Posted by sedge on 16-Feb-2011 19:00

Thanks Mahesh

Can you suggest a way to perform the selection?

I have tried with XSLT but, again, I don't know how to use a Message Part as the comparison value.

Regards

Steve

Posted by mnair on 16-Feb-2011 21:00

Hi Steve,

With message mapping you have to use a static xpath for now. The same holds true with the transform action in message mapping as we have not yet exposed XSLT parameters. So some options (none very attractive):

- Create separate steps with message mapping xpaths relevant to each environment and then use a CBR step to route to the appropriate step.

- Use the transformation service where you can pass sytlesheet parameters as a runtime parameter. Then populate these runtime parameters in message mapping.

- Write a custom service

Thanks

-Mahesh

Posted by sedge on 17-Feb-2011 00:56

Hi Mahesh

Can you help me out with this one:

- Use the transformation service where you can pass sytlesheet parameters as a runtime parameter. Then populate these runtime parameters in message mapping.

Should I do it the same way as for the Dynamic URL ( #{esbp.params['SomeRuntimeParam']} where in the stylesheet)?

I tried it and got this error:

com.sonicsw.esb.expression.ExpressionException: Failed to evaluate and set expression: #{esbp.params['Environment']}

Thanks

Steve

This thread is closed