1
votes

I have to set an Hadoop endpoint for the outsequence of a proxy service in WSO2 ESB. I should convoy a WS response into an Hadoop file repository. Here is the syntax for the PUT command that would write the file on Hadoop: 2-step commands for file-writing

How to implement a working proxy that executes this 2 steps in the outsequence for saving a WS response on Hadoop?

1

1 Answers

1
votes

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:

  1. First you make a <call> to the hadoop endpoint and get the url to save data.

  2. 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"/>

  3. 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).

  4. 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.

  5. 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.