Friday, August 5, 2016

How to set message headers for a apache camel restlet request

It is simple to set message headers for camel restlet request (Here we follow XML method to add those headers to a camel routing).

Following route will send a GET request to  http://192.168.1.20:8081/abcsys/services/esbInboundAdaptorServiceRest/V1.0/receiveMessage including Basic Authentication headers with username admin and password admin. A query param also get appended to the URI as http://192.168.1.20:8081/abcsys/services/esbInboundAdaptorServiceRest/V1.0/receiveMessage?message=new message

<route>

                    <!-- Set the query parameters to URI -->
                    <setHeader headerName="CamelHttpQuery">
                        <simple>message=new message</simple>
                    </setHeader>

                    <!-- Set the authentication header username for endpoint authorization -->
                    <setHeader headerName="CamelRestletLogin">
                        <simple>admin</simple>
                    </setHeader>

                    <!-- Set the authorization header password for endpoint authorization -->
                    <setHeader headerName="CamelRestletPassword">
                        <simple>admin</simple>
                    </setHeader>

                    <to
                        uri="restlet:http://192.168.1.20:8081/abcsys/services/esbInboundAdaptorServiceRest/V1.0/receiveMessage" />


</route>

Refer this for possible lists of headers that can be set to restlet requests.

No comments:

Post a Comment