MFP.Server
Method Attributes | Method Name and Description |
---|---|
MFP.Server.addResponseHeader(input, value)
Changes the response headers when using adapters.
|
|
Gets the authenticated user information.
|
|
Returns a reference to the Java™ HttpServletRequest object that was used to invoke an adapter procedure.
|
|
MFP.Server.getPropertyValue(options)
Gets the value for the given property name.
|
|
Gets the introspection data of the access token provided in the request.
|
|
MFP.Server.invokeHttp(options)
Calls an HTTP service.
|
|
MFP.Server.invokeProcedure(invocationData)
Invokes a procedure exposed by another MobileFirst® JavaScript adapter.
|
|
MFP.Server.invokeSQLStatement(options)
Calls a prepared SQL statement.
|
|
MFP.Server.invokeSQLStoredProcedure(options)
Calls a stored procedure on a database.
|
|
MFP.Server.logActivity(activityType, deviceContext)
Reports user activity for auditing or reporting purposes.
|
Property | Description |
---|---|
name | HTTP header name. A string. |
value | HTTP header value. A string. Cannot be null. |
MFP.Server.addResponseHeader("Expires","Sun, 5 October 2014 18:00:00 GMT");
{ "id":"test", "authenticatedBy":"UsernamePasswordCheck", "isSuccessful":true, "authenticatedAt":1470314267025, "attributes":{}, "displayName":"test" }The invocation results object contains the following properties:
Property | Description |
---|---|
attributes | Map of attributes |
authenticateedAt | Time of authentication |
authenticateedBy | Security check authenticed for user |
displayName | Display name of the user |
id | ID of the user |
var request = MFP.Server.getClientRequest();
var userAgent = request.getHeader("User-Agent");
{ "mfp-application": { "id":"com.ibm.mfpstarterweb", "clientPlatform":"web" }, "exp":1470311497928, "username":"anonymous", "mfp-device": { "id":"6747046e-0393-ced4-632d-19fe2af0fa87", "platform":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36", "hardware":"MacIntel", "status":"ACTIVE", "displayName":null }, "scope":"RegisteredClient", "isSuccessful":true, "mfp-user":null, "active":true, "client_id":"e3d0a789-6ec1-4451-930d-12d06a1834d0", "mfp-checks":{} }The invocation results object contains the following properties:
Property | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
client_id | Client identifier | ||||||||||||
exp | Expiration of the token | ||||||||||||
mfp-application | Application Data
|
||||||||||||
mfp-device | Device Data
|
||||||||||||
mfp-user | User Data
|
||||||||||||
mfp-checks |
custom introspection data provided by the security checks. The data is provided as a map between the name of the security check and the custom introspection data it provided. The map includes only security checks that provided a non-empty custom introspection data. |
Property | Description |
---|---|
method | Mandatory. Defines the HTTP method. Valid values are get, post, put, and delete . |
returnedContentType | Optional. Defines the type of content that is returned by the called HTTP service, overriding the HTTP response’s MIME type. If this parameter is not provided, the MobileFirst® Server handles the response according to the MIME type. If it is provided, the MobileFirst Server handles the response according to the indicated value. The field can receive the following values:
|
returnedContentEncoding | Optional. Defines the encoding of the returned content. Default is utf-8 . |
path | Mandatory. Defines the path of the URL defining the HTTP service. |
parameters | Optional. Defines the set of parameters that need to be passed to the HTTP service. |
headers | Optional. Defines the headers for the HTTP request. |
cookies | Optional. Defines cookies to be passed with the HTTP request. |
body | Defines the content of the request body.
body.content must be a string. If you are explicitly creating a DOM object, such as in:
var request = <soap:Envelope> … </soap:Envelope> , you must convert the object to a
string before you assign it to body.content ,
for example: request.toString();
|
transformation | Optional. If defined, the response of the service undergoes the defined XSL transformation. If the service returns HTML, the MobileFirst Server first converts the response to XHTML, and then runs the XSL transformation on the XHTML response. |
connectionTimeoutInMilliseconds | Optional.
The timeout (in milliseconds) until a connection to the back-end can be established. The default value is 30000.
By passing a value for connectionTimeoutInMilliseconds , you can override the value defined for
connectionTimeoutInMilliseconds in the |
socketTimeoutInMilliseconds | Optional.
The timeout (in milliseconds) between two consecutive packets, starting from the connection packet. The default value is 30000.
By passing a value for socketTimeoutInMilliseconds , you can override the value defined for
socketTimeoutInMilliseconds in the |
transformation
property, the MobileFirst Server executes the transformation on the
result of Step 1. The transformation should convert its XML input
to JSON. If no transformation was defined, the MobileFirst Server
automatically converts the result of Step 1 to JSON.var response = MFP.Server.invokeHttp(invocationData);
response.responseHeader; // responseHeader property contains HTTP response headers
response.statusCode; // statusCode property contains HTTP response status code
Property | Description |
---|---|
adapter | Mandatory. A string that contains the name of the adapter as specified when the adapter was defined. |
procedure | Mandatory. A string that contains the name of the procedure as specified when the adapter was defined. |
parameters | Optional. An array of parameter values that are passed to the back-end procedure. A parameter can be a scalar or an object. |
{ isSuccessful: Boolean, errorMessages: ["Error Msg1", ...], // Application object returned by procedure }The invocation results object contains the following properties:
Property | Description |
---|---|
isSuccessful | Identifies whether the function invocation succeeded or failed. Valid values are:
|
errorMessages | Optional. An array of strings that contain error messages. If no errors are provided, the returned array is empty. |
Application object | Any object that is returned by the procedure. |
;
{ //Mandatory preparedStatement : prepared-statement-variable, //Optional parameters: [value-1, value-2, .... ] }The
invokeSQLStatement
function accepts the following JSON
block of parameters:
Property | Description |
---|---|
preparedStatement | Mandatory. A string representing the SQL statement. |
parameters | Optional. An array of parameters to the prepared statement. |
function procedure1(param) { return MFP.Server.invokeSQLStatement({ preparedStatement : "select transactionType, transactionAmount, transactionId, toAccount, fromAccount, transactionDate from TRANSACTIONS where fromAccount = ?",, parameters : ["12345"] }); }Then, assuming that the result set is:
transactionType transactionAmount transactionId toAccount fromAccount transactionDate ------------------------------------------------------------------------------------------------- "Funds Transfer" 180.00 "W06091500863" "54321" "12345" 1236762519000 "ATM Withdrawal" 130.00 "W214122/5337" NULL "12345" 1236416979000The JSON result is:
{ "isSuccessful":true, "resultSet":[ { "transactionType":"Funds Transfer", "transactionAmount":180.00, "transactionId":"W06091500863", "toAccount":"54321", "fromAccount":"12345", "transactionDate":1236762519000 }, { "transactionType":"ATM Withdrawal", "transactionAmount":130.00, "transactionId":"W214122/5337", "toAccount":null, "fromAccount":"12345", "transactionDate":1236416979000 } ] }
{ //Mandatory procedure : procedure-name, //Optional parameters: [value-1, value-2, ... ] }
transactionType transactionAmount transactionId toAccount fromAccount transactionDate ------------------------------------------------------------------------------------------------- "Funds Transfer" 180.00 "W06091500863" "54321" "12345" 1236762519000 "ATM Withdrawal" 130.00 "W214122/5337" NULL "12345" 1236416979000The JSON result is:
{ "isSuccessful":true, "resultSet":[ { "transactionType":"Funds Transfer", "transactionAmount":180.00, "transactionId":"W06091500863", "toAccount":"54321", "fromAccount":"12345", "transactionDate":1236762519000 }, { "transactionType":"ATM Withdrawal", "transactionAmount":130.00, "transactionId":"W214122/5337", "toAccount":null, "fromAccount":"12345", "transactionDate":1236416979000 } ] }
MFP.Logger
instead.