To operate, simply start the AL called
FeedServer. Be sure an use "Standard (Run to completion)" mode in order to get AL Pooling. The HTTP Server mode Connector will bind to port 80 and wait for incoming REST requests.
For example,
http://localhost by itself will return the list of available Feeds. This is provided by the included
AssemblyLine called
Feeds which has a scripted Connector that iterates through all ALs defined in the running Config. Of course, the names 'FeedServer' and 'Feeds' are skipped, as you can see in the
Feeds AL.
If you request a specific feed like this:
http://localhost/Levels then the FeedServer executes an AL called
Levels. This
AssemblyLine must either create the XML return string (RSS feed format) in an Attribute called "xml_return"; or you must set up Work Attributes named after RSS tags for each Entry cycled in the AL. For more information on which Attribute names you need to return, see the
Map2RSS AttributeMap in the library folder; here is a complete list that you can select, copy and paste into your own map.
Any parameters that you tag onto the REST call will be automatically parsed into Attributes for you. These Attributes are available to your Feed AL via the Operation Entry -- which is a persistent Entry object that holds info like parameters passed in by the calling AL. So for example, say you have a Feed AL called
FindPerson that you invoke like this:
http://localhost/FindPerson?UID=ABCDE
Then when your Feed AL is called you can access the UID query string parameter like this:
task.logmsg("--> Looking for UID = " + task.getOpEntry().getString("http.qs.UID"));
The two example Feed ALs included in this Config are
Buffalo and
Levels.
Buffalo reads some entries from the public LDAP Server at Buffalo University in New York;
Levels uses scripted Parsers to scrape websites in Norway in order to return the current water level of Norwegian rivers.
Both of these Feed ALs implement two parameters:
- pageSize - number of RSS items to return per page (default 10)
- page - page number (default 1)
Page handling is done by skipping to the specified
page and then returning
pageSize items.
--
EddieHartman - 11 Oct 2008