First, in the inSequence, you can do a call to request the url using call mediator.
<call>
<endpoint>
<address uri="http://localhost:9000/services/YourService"/>
</endpoint>
</call>
Next, you can extract the header from the above response and set it as the 'To' header for the next request.
Then use the send or call mediator to send the content using a 'default' endpoint (the default endpoint sends the message to the correct address by looking at the 'To' header).
<header name="To"
scope="transport"
expression="get-property('redirectUri')"/>
Example 5 in this page describes how to use default (dynamic) endpoints.
UPDATE:
Since you need to call an external REST service and save it to hadoop, the basic flow can look like following:
First you make a <call>
to the hadoop endpoint and get the url to save data.
From the above response, extract the header and save it to a property.
<property name"redirectUri" expression="get-property('hadoop_response_header_name')" scope="transport"/>
Next you can call the rest service using call mediator again. Before calling this, you will probably have to build a json payload with the Payload Factory mediator. Also make sure when you declare the endpoint here, add the correct format as 'rest' (read a bit on address endpoints on this).
When you receive response from the rest service, you can do any necessary modification to the response received using payload factory again to build a properly formatted request to call the hadoop endpoint.
Finally you can send the request to the hadoop endpoint. Before calling send mediator here, you'll need to set the 'To' header as given above (using the previously extracted property 'redirectUri') and also use a default endpoint.
You'll need to read a bit on endpoints, payload factory mediator, call mediator, property mediator and header mediator to get this working.