OpenLegacy provides an out-of-the-box HTTP REST application.

This means that once you generate an OpenLegacy API into a newly creaed project of type openlegacy-rest-new, and the Web server starts, all screen entities classes are exposed as URLs which returns and consumes XML and JSON content.

Example:
Given that you have an screen API class: inventory.ItemsList

You can get it in XML format over http using the following URL:
http://localhost:8080/YourAppName/ItemsList

With Content-Type=”application/xml” and Accept=”application/xml” http header, the following XML will be returned:

Code Snippet:

With Content-Type=”application/json” and Accept=”application/json” http header, the following JSON content will be returned:

Code Snippet:

SPECIAL NOTES:

  • This example assumes login has been performed, and ItemsList API has @ScreenNavigation defined (how to access this screen)
  • The positionTo node represents the field ItemsList.positionTo in the Java model
  • The focusField node represents the field the focus is on
  • ItemListRows nodes represent a list of table rows
  • Paths nodes represent location of other entities and can be accessed using /ENTITY-NAME
  • Actions nodes represent possible actions on the screen and can be used for POST screen entity using /ENTITY-NAME?action=

Sending XML or JSON content

To perform a send operation, you’ll be required to send the child node “screenEntity” with new values within its child. Nodes.focusField can be populated as well.

The target URL should be /ENTITY-NAME?action= (as specified in the returns actions nodes). If no action is specified in the URL, ENTER key will be performed.

No response is returned beside HTTP status code 200 if OK, and HTTP status code 400 if not.

Additional URLs (all with XML or JSON specified headers):

  • “/” – will return the first screen of the application, typically login screen
  • “/logoff” – if you wish to logoff the host session
  • “/menu” – returns a menu of all application screens