HTTP adapter - Communicating with HTTP back-end systems
By using IBM MobileFirst Platform Foundation HTTP adapters, you can send GET or POST HTTP requests and retrieve data from the response headers and body. HTTP adapters work with RESTful and SOAP-based services and can read structured HTTP sources such as RSS feeds.
The adapter is configured with XML to define the adapter properties and procedures. Optional: It uses XSL to filter received records and fields.
Creating the adapter
In MobileFirst Studio, create an adapter and select the HTTP Adapter type. A standard HTTP adapter structure is created.
Settings and metadata are stored in the adapter XML file. You can use either the Design or Source editor to modify the adapter XML file.
To edit the adapter XML file, you must:
- Set the protocol to HTTP or HTTPS
- Set the HTTP domain to the domain part of HTTP URL
- Set the TCP Port
Declare the required procedures below the connectivity element.
Some parts of the URL are constant; for example, http://example.com/. They are declared in the XML file. Other parts of the URL can be parameterized; that is, substituted at run time by parameter values that are provided to the MobileFirst procedure.
The following URL parts can be parameterized.
- Path elements
- Query string parameters
See the "The connectionPolicy element of the HTTP adapter" user documentation topic for advanced options for adapters, such as cookies, headers, and encoding.
The mandatory parameters to call the procedure are
The procedure can be parameterized at run time.
To call an HTTP request, use the
Provide an input parameters object, which must specify:
- The HTTP method:
- The returned content type:
- The service
- The query parameters (optional)
- The request body (optional)
- The transformation type (optional)
See the "WL.Server.invokeHttp" user documentation topic for a complete list of options.
XSL transformation filtering
You can apply XSL transformation to the received data, for example to filter the data. To apply XSL transformation, specify the transformation options in the input parameters of the procedure invocation.
Creating a SOAP-based service request
You can use the
WL.Server.invokeHttp method to create a SOAP envelope, which can be sent directly.
WL.Server.invokeHttp(options) method is used to call a request for a SOAP service.
The Options object must include the following properties:
pathproperty: a service path
content(SOAP XML as a string) and
Back-end service discovery
If you are developing HTTP adapters for SOAP (or SAP) services, you can reduce development time by using the Discover Back-end Services tool to autogenerate the adapter with procedures that are based on the provided WSDL.
Right-click the services folder in a MobileFirst project and choose Discover back-end services. Select the type of service: SAP or SOAP.
Add the services location to use and select the service that you want to add to the adapter. Repeat for each service that you want to add. The service will be added to the same adapter.
MobileFirst Studio will then auto-generate an adapter.
For more information, review the "Generating adapters with the services discovery wizard" user documentation topic.
Click to download the Studio project.▲