> in camel example here : > > <camelContext id="xpathHeaderNameTest"<b> > <xpath headerName="invoiceDetails">/invoice/@orderType = 'premium'</xpath>
Means a header "invoiceDetails" with data like <invoice @orderType="premium"/> > <log message="***************** ${headers.RouteConfiguration}***************" /> > <xpath headerName="ROUTE_CONFIGURATION_HEADER">authorizationCheck/text()='enabled'< /xpath> Which header do you want to access? - RouteConfiguration - ROUTE_CONFIGURATION_HEADER Again header structure for ROUTE_CONFIGURATION_HEADER is something like <authorizationCheck>enabled</authorizationCheck> I played a little bit on headers (using JavaDSL) if this helps. Jan import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; public class XPathHeaderTest extends CamelTestSupport { @Test public void header() throws InterruptedException { getMockEndpoint("mock:end").expectedHeaderReceived("NO_AUTHENTIFICATION", true); template.sendBodyAndHeader("direct:header", "<data>123</data>", "ROUTE_CONFIGURATION_HEADER", "<authorizationCheck>disabled</authorizationCheck>"); assertMockEndpointsSatisfied(); } @Test public void headerAuth() throws InterruptedException { getMockEndpoint("mock:end").expectedHeaderReceived("WITH_AUTHENTIFICATION", true); template.sendBodyAndHeader("direct:header", "<data>123</data>", "ROUTE_CONFIGURATION_HEADER", "<authorizationCheck>enabled</authorizationCheck>"); assertMockEndpointsSatisfied(); } @Test public void headerUnknown() throws InterruptedException { getMockEndpoint("mock:end").expectedHeaderReceived("NO_AUTHENTIFICATION", true); template.sendBody("direct:header", "<data>123</data>"); assertMockEndpointsSatisfied(); } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { String headerName = "ROUTE_CONFIGURATION_HEADER"; // ensure that the config-header is set, otherwise xpath on that wont work: // org.apache.camel.builder.xml.InvalidXPathExpression: // Invalid xpath: /authorizationCheck='enabled' with headerName ROUTE_CONFIGURATION_HEADER. // Reason: javax.xml.xpath.XPathExpressionException from("direct:header") .choice() .when().simple("${in.header." + headerName + "}").to("direct:withConfigHeader") .otherwise().to("direct:withoutConfigHeader"); from("direct:withConfigHeader") .choice() .when().xpath("/authorizationCheck='enabled'", headerName) .setHeader("WITH_AUTHENTIFICATION", constant(true)) .otherwise() .setHeader("NO_AUTHENTIFICATION", constant(true)); from("direct:withoutConfigHeader") .setHeader("NO_AUTHENTIFICATION", constant(true)) .to("mock:end"); } }; } }