Learn about implementing JavaScript adapters.
The IBM MobileFirst™ Platform Server does not rely on HTTP sessions. In a deployment that involves multiple nodes, a client request can be processed by one server in a cluster and the next request by another. You should not rely on global variables to keep data from one request to the next.
Adapter calls are not designed to return huge chunks of data because the adapter response is stored in MobileFirst Server memory as a string. Thus, data that exceeds the amount of available memory might cause an out-of-memory exception and the failure of the adapter invocation. To prevent such failure, you configure a threshold value from which the MobileFirst Server returns gzipped HTTP responses. The HTTP protocol has standard headers to support gzip compression. The client application must also be able to support gzip content in HTTP.
WLResourceRequest req = new WLResourceRequest(new URI("/adapters/sampleAdapter/procedure"), WLResourceRequest.GET);
req.addHeader("Accept-Encoding", "gzip");
req.send(myListener);
var request = new WLResourceRequest('/adapters/sampleAdapter/procedure', WLResourceRequest.GET);
request.addHeader('Accept-Encoding',’gzip’);
request.send().then(
function(response) {
// success flow, the result can be found in response.responseJSON
},
function(error) {
// failure flow
// the error code and description can be found in error.errorCode and error.errorMsg fields respectively
}
);