Does Mobilefirst provide a provision to access web services directly? - ibm-mobilefirst

I am developing a native android app on MobileFirst platform. Does MobileFirst provide any code to connect to a web service instead of going through adapters? This is basically only for Native Android development and not for Hybrid app.

The MobileFirst SDK only provides what is required to work with features provided by MobileFirst, such as connecting to various backends using Adapters with the added benefit of the MobileFirst security framework, and other features.
If you have a need to connect to backends not via MobileFirst, use other common client-side utilities to achieve that.

I used the following code and it worked.
WLResourceRequest request = new WLResourceRequest("Actual server path here", GET);
request.addHeader(new BasicHeader("IfAnyHeader", "here"));
request.send(new ResponseListener());

If you are using native Android, you could use volley (or similar) to call external web services or REST apis.
http://developer.android.com/training/volley/index.html
Nothing to do with MobileFirst though, all totally standard Android native coding.

Related

Using IBM MobileFirst HTTP Adapters for web application

I have a hybrid mobile app, which is developed on IBM MobileFirst Platform. I have you HTTP adapters for rest api calls. Now i am planning to create a full scale web application in AngularJS 2.0 & BootStrap. Will it be possible to use those adapters in that web application? Please advice.
MobileFirst Foundation does not care for the technology used to create the application... be it native or web. Ionic-based, Angular, Cordova etc... it doesn't matter.
Adapters sit on the server and you make a call to the server to use them... so it doesn't matter what you use in the client.

Can I use a MobileFirst app without the MobileFirst server?

Can I consume a web service in a MobileFirst application without a MobileFirst server?
Yes, you can use your MobileFirst app without the need to connect to a MobileFirst server.
The drawback of not using the MobileFirst server is that you'll be loosing all of the features it provides like authentication, security, adapters, unified push notifications, direct update (for hybrid), remote disable, and other features.
If you want to make a request to any endpoint you can use WLResourceRequest (available from version 7.0 onwards) or any other native method to make HTTP requests.
Information on how to use WLResourceRequest
Android:
https://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.apiref.doc/html/refjava-worklight-android-native/html/com/worklight/wlclient/api/WLResourceRequest.html
Hybrid:
https://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.apiref.doc/html/refjavascript-client/html/WLResourceRequest.html?cp=SSHS8R_7.0.0%2F9-0-0-1-31
iOS: https://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.apiref.doc/html/refobjc-worklight-ios/html/interface_w_l_resource_request.html%23a004749b662c6f4a55a3b76e47f7e6062?lang=en
If the call is for example to an external resource you can use the same plain regular AJAX calls as you would anywhere else.
If the resource is protected by MobileFirst Platform, then you must use adapters. Adapters must go through the MobileFirst Server.
Use it like simple IDE to develop application(Native and hybrid).You can use client side API also that do not connect to the mobilefirst server.
You cannot use a mobile first app if you are using MF 7.0 or higher without a server, as soon as you launch the app it invokes an authorization request something like following:
<< domain >>/<< context >>/authorization/v1/clients/instance
Which connects to your workflight server and if it doesnt get response it will fail.
As far as invoking a web service is concerned that is just javascript if you are doing hybrid you can use AJAX as mentioned in another answer. If you are building native IOS or Android you can invoke http request using sdk libraries.
Cheers !

Usage of already deployed REST service in mobile application using IBM Mobile First

I've published a native android application which uses a services with response in JSON format. Now, I want to develop a Hybrid application using IBM Mobile first platform. I want to use the same service here in this case also. I'm not able to findout the mechanism to do so. Anyone please suggest me some solution.
I assume that you intend to build your hybrid app using HTML, CSS and JavaScript.
You could directly call the service using standard JavaScript
XMLHttpRequest(serviceUrl)
But you probably will use some framework such as AngularJS - such frameworks really do pay off in the long run - and in which case you have nice APIs
$http.get(serviceUrl).then(doSomeWork);
However this raw JavaScript approach does not exploit the MobileFirst programming model. We tend to find that using a Mobile Gateway architectural pattern, where MobileFirst adapters act as the gateway, pays off as your application becomes more complex. The adapters provide a security model and can implement aggregation and filtering so that precious mobile bandwidth is used more efficiently.
Hence we recommend that you build adapters, as described in the links given by Idan, and then you use the MobileFirst API to call the adapters:
WL.Client.invokeProcedure( ... );
Starting MobileFirst Platform Foundation 7.0, both the JS framework (for Hybrid apps) and the Native SDK (for iOS and Android) provide REST support. You can accomplish this using either JavaScript adapters or Java adapters.
Read the following tutorials explaining how to use MFP adapters:
Server-side development
If you're interested in Java adapters as well, take a look at these videos as well:
Getting familiar with IBM MobileFirst Platform Foundation Java Adapters [Part 1]
Getting familiar with IBM MobileFirst Platform Foundation Java Adapters [Part 2]

MobileFirst configuration for mapping service ArcGIS

We are exploring IBM Mobilefirst capabilities with a mapping application. We are using Esri ArcGIS Mapping service.
Where can I find the available resources or sample tutorial to use Esri ArcGIS with IBM MobileFirst hybrid applications?
Not every available tool out there has guides for IBM Worklight/MobileFirst.
It looks like Esri ArcgGIS has a developer website.
You should start there: https://developers.arcgis.com/en/sign-up/?origin=developer
Read how to integrate it into applications.
If there are SDKs then you will need to integrate those like you would any other SDK - that is outside of the Worklight/MFP scope (the integration).
I would assume that if it an SDK, you could then add a Cordova plug-in that would allow you to access that SDK from your app, or even better you could use the Send Action feature to bridge between Web and Native and vice versa.
Adding native functionality to hybrid applications with Apache Cordova
Action Sender

IBM Worklight - Any advantages for when developing a Mobile web app?

Going through the IBM Worklight product documentation,the product looks great for building hybrid or native applications. However for building mobile web (with responsive web design) what are the specific advantages one can get from worklight?
For (the) Mobile Web (environment), I don't think that at this time there is much left.
However, you do still:
get to use Worklight Adapters and its extensive integration abilities, which do make it easier to connect to various backends
use Cordova to access some device native capabilities
use the WL Client JavaScript API