+

Search Tips   |   Advanced Search

Overview of MobileFirst adapters

Adapters run on the server and connect to mobile apps.

Adapters are the server-side code of applications that are deployed on and serviced by MPF. Adapters connect to enterprise applications (otherwise referred to as back-end systems), deliver data to and from mobile applications, and perform any necessary server-side logic on this data.

With IBM MobileFirst Platform Foundation, create and configure adapters manually, or we can also automatically generate SAP Netweaver Gateway or SOAP adapters with the services discovery wizard.

Starting with MPF v6.3, changes were made to the XML definition and behavior of adapter timeout and concurrency.


Benefits of MobileFirst adapters

Adapters provide various benefits, as follows:


The adapter framework

The adapter framework mediates between the mobile apps and the back-end services. A typical flow is depicted in the following diagram. The app, the back-end application, and the JavaScript code and XSLT components in the MobileFirst Server are supplied by the adapter or app developer. The procedure and auto-conversions are part of MPF.

Figure 1. The adapter framework

  1. An adapter exposes a set of services, called procedures. Mobile apps invoke procedures by issuing Ajax requests.

  2. The procedure retrieves information from the back-end application.

  3. The back-end application then returns data in some format.

    • If this format is JSON, the MobileFirst Server keeps the data intact.

    • If this format is not JSON, the MobileFirst Server automatically converts it to JSON. Alternatively, the developer can provide an XSL transformation to convert the data to JSON. In such a case, the MobileFirst Server first converts the data to XML (if it is not in XML already) that serves as input for the XSL transformation.

  4. The JavaScript implementation of the procedure receives the JSON data, performs any additional processing, and returns it to the calling app.

    • Writing an adapter that pulls large amounts of data and transfers it to the client application is discouraged because the data must be processed twice: once at the adapter and once again at the client application.

    • HTTP POST requests are used for client-server communications between the MobileFirst application and the MobileFirst Server. Parameters must be supplied in a plain text or numeric format. To transfer images (or any other type of file data), they must be converted to base64 first.


Anatomy of adapters

MobileFirst adapters are developed using XML, JavaScript, and XSL. Each adapter must have the following elements:

The files are packaged in a compressed file with a .adapter suffix (such as myadapter.adapter).

The root element of the XML configuration files is <adapter>. The main subelements of the <adapter> element are as follows:

The structure of the <adapter> element is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter>
<description> 
<connectivity>
<connectionPolicy> 
<loadConstraints>
</connectivity>
<procedure /> <!-- One or more such elements -->
</wl:adapter>


The HTTP adapter

The MobileFirst HTTP adapter can be used to invoke RESTful services and SOAP-based services. It can also be used to perform HTML scraping.

Use the HTTP adapter to send GET, POST, PUT, and DELETE HTTP requests and retrieve data from the response body. Data in the response can arrive in XML, HTML, or JSON formats.

We can use SSL in an HTTP adapter with simple and mutual authentication to connect to back-end services. Configure the MobileFirst Server to use SSL in an HTTP adapter by implementing the following steps:

Note however that SSL represents transport level security, which is independent of basic authentication. It is possible to do basic authentication either over HTTP or HTTPS.


The SQL adapter

Use the MobileFirst SQL adapter to execute parameterized SQL queries and stored procedures that retrieve or update data in the database.


The Cast Iron adapter

The MobileFirst Cast Iron adapter initiates orchestrations in Cast Iron to retrieve and return data to mobile clients.

Cast Iron accesses various enterprise data sources, such as databases, web services, and JMS, and provides validation, aggregation, and formatting capabilities.

The Cast Iron adapter supports two patterns of connectivity:

The Cast Iron adapter supports the invocation of a Cast Iron orchestration over HTTP only. Cast Iron Template Integration Projects (TIPs) are provided in Cast Iron as examples of this technique, and for you to use as a basis for our own orchestrations. See Cast Iron documentation.

Cast Iron uses the standard MobileFirst notification adapter and event sources to publish notification messages to be delivered to devices using one of the many notification providers.

For information about defining event sources, see the createEventSource method in the WL.Server class.

Cast Iron Template Integration Projects (TIPs) are provided in Cast Iron as examples of this technique, and for you to use as a basis for our own notification scenarios. See Cast Iron documentation.

To protect the notification adapter, use basic authentication.


The JMS adapter

The MobileFirst JMS adapter can be used to send and receive messages from a JMS-enabled messaging provider. It can be used to send and receive the headers and body of the messages.


Troubleshooting a Cast Iron adapter – connectivity issues

Symptom: The MobileFirst adapter cannot communicate with the Cast Iron server.

Causes:


Parent topic: Develop the server side of a MobileFirst application