0

I have some static files (some are HTML, some are images and some are pure data files - like .csv or .xls etc) that I want to share through the ESB. I can make that happen if I run a separate HTTP server that will receive the request for these through ESB. Instead, I like to handle it in ESB itself. Based on the incoming request URL (say HTTP GET request - http://myesb.com:8280/getstatus.html ), I like to pull these static files from the local server's folders.

I tried the VFS method and it looks like has built in "refresh" mechanism that I don't want. I want to "GET" these data only when the clients are requesting for it.

In short, I like to have a simple mapping done like this:

http://myesb.com:8280/getstatus.html will fetch the contents of /var/myapp/status/appstatus.html file.

Update I did the following sequence - don't know how to make it work :(

<sequence xmlns="http://ws.apache.org/ns/synapse" name="app1status">
   <in>
      <log level="custom">
         <property name="Reached app1status page - in" value="app1 Status"/>
         <property name="transport.vfs.ContentType" value="text/html"/>
         <property xmlns:ns="http://org.apache.synapse/xsd" name="TRPURL:" expression="get-property('From')"/>
      </log>
      <property name="transport.vfs.FileURI" value="vfs:file:///opt/platform/traffic/app1status1.html" scope="transport" type="STRING"/>
      <property name="HTTP_METHOD" value="GET"/>
      <property name="ClientApiNonBlocking" action="remove" scope="axis2"/>
      <header name="To" action="remove"/>
      <property name="RESPONSE" value="true" scope="default" type="STRING"/>
   </in>
   <out>
      <log level="custom">
         <property name="::::::Out:::::Reached app1status" value=" From OUT"/>
         <property name="messageType" value="text/html"/>
         <property name="ContentType" value="text/html"/>
      </log>
      <send/>
   </out>
</sequence>

Note the following in the <in> mediator:

<property name="transport.vfs.FileURI" value="vfs:file:///opt/platform/traffic/app1status1.html" scope="transport" type="STRING"/>

My intent is to get the content of the file appstatus1.html retrieved and send back as the response. But I am not able to get the contents retrieved and added to the "RESPONSE"

Let me know how it can be done.

Thanks for your time.

1 Answers1

0

Define a RESTAPI and based on GET/PUT pull or post data to your server.

Ratha
  • 9,434
  • 17
  • 85
  • 163
  • Can you elaborate on the way I can specify the local file to be sent in the api? What I am trying to do is this: I want to enable or disable traffic for a particular application using a HTML file (a regular html file in a local folder). If ESB can find and fetch the contents of the HTML file to the caller (in this case external load balancer), the traffic will continue. If ESB didn't find the file and returned HTTP 404, the load balancer will cease sending traffic for the particular application. I really appreciate if you can provide a sample configuration for using API to send a static file. – Sajumon Joseph Jul 31 '13 at 17:20
  • For now, I am using RESTAPI and ended up hosting the HTML page on another web server and everything worked. I wanted to have the ESB server itself handle the HTML request (become a basic web server), but haven't figured out that one yet :( - – Sajumon Joseph Aug 28 '13 at 11:20