REST-Compliant Web Services

You can use the UHTTP component to create and use REST-compliant web services.

The UHTTP component is a simple HTTP client that is used for sending and receiving HTTP requests and responses. It enables you to integrate communication with web sites (REST-compliant APIs), implement basic browser functionality, and so on. Uniface UHTTP component operations enable you to configure and submit HTTP requests to REST APIs from vendors such as Amazon, DropBox, Google Drive, and Microsoft OneDrive, and to handle the received responses. For more information, see UHTTP.

In its most simple form, an HTTP request is a URL to which a message is sent. The URL identifies a particular resource. The message starts with a number of headers that have a very specific and documented meaning. They describe the body of the message, which follows the headers. A response has the same structure.

Many REST-compliant APIs support the ability to upload and download a file, where the file contents form the complete body of the request or response. The file, and what you want to do with it, are specified in the URL or in a combination of the URL and headers. The API may return intermediate responses that redirect the caller to the actual file location, but at some point, the file is transferred using the complete body.

REST-compliant APIs can vary greatly. Some use query strings in the URL, others rely on propriety headers. Body contents may be JSON or HTML, and may be structured differently using different keywords. Some vendors require an interactive logon, in which case batch processing can be difficult.

REST APIs do not use WSDL to describe their interfaces and behavior, so you must consult the vendor documentation for information about the API.

The operations of the UHTTP component are designed to provide a great deal of flexibility. They provide the basic functionality for configuring and submitting the request and handling the response, while enabling you to prepare the list of headers and assemble the message content, which may consist of a text or binary file.

Using ProcScript commands and the UHTTP operations, you can prepare and submit the required query strings, headers, key words, and security mechanism, and anticipate the specific responses. Both text and binary file transfer are supported.

The Uniface UHTTP component operations enable you to:

  • Send an HTTP request using the specified HTTP method, such as PUT or POST for file upload and GET for file download.
  • Create the body of an HTTP request either from your own textual content, or from a file (or chunk of it) for upload
  • Use a response body either as a textual response or as a file (or chunk of it) for download.
  • Get information about a file after it is loaded into the request or response

For more information, see UHTTP.

Limitations

Using the file operations in the UHTTP client,

  • It is not possible to mix metadata and the file contents in the body of an HTTP request/response. Although some REST APIs offer multi-part messages, these are not supported by the UHTTP file operations.
  • The Uniface static server page can respond to a GET method, so you can enable users to download a file. However, it does not support uploading a file to a Uniface application.