Search code examples
apache-camelspring-camelcamel-http

How do I add only the parameter value to the endpoint in camel?


<camel:from id="_from2" uri="timer://foo?repeatCount=1"/>
            <camel:to id="_to2" uri="DBSQLComponent:{{sql.testQuery}}"/>
            <log id="_log4" message="Received ${body.size()} records from the poller query"/>
            <log id="_log5" message="Message Body= ${body}"/>
            <to id="_to3" uri="log:output?showAll=true"/>
            <camel:process id="_processNewNotifications" ref="newNotifications"/>
            <setHeader headerName="CamelHttpMethod" id="setHeader4">
                <constant>GET</constant>
            </setHeader>
            <setHeader headerName="Content-Type" id="_setHeader5">
                <constant>application/json</constant>
            </setHeader>                                                                                                                                                                                                                        
            <setHeader headerName="CamelHttpQuery" id="setHeader7">
                <simple>Id=${property.POList}</simple>
            </setHeader>
            <inOut id="_createPO" uri="cxfrs:bean:purchaseOrderDetailsEndpoint+${property.POList}"/>
</camel>

I am new to Camel and I am struggling to find resources to append only the value of the parameter? For the current code, it will add ?Id=${property.POList} to the endpoint. I only want the value ${property.POList} to be added to the rest endpoint. Please advise the best course of action to adding only a value to the endpoint in Spring DSL. Thank you!


Solution

  • You're setting a special header called "CamelHttpQuery" which, when the exchange is passed to the CXFRS component will add its contents to the CXF URL as a HTTP query (that's why you're seeing the ? sign being automatically added).

    You could try using the header "CamelHttpPath" instead, which should set the resource path.