IBM Worklight encrypt and compact - ibm-mobilefirst

The Worklight provides a way to encrypt the data on the Worklight Server in adapter, compress and send to the client? Or do I need encryption manually?

Using HTTPS in Worklight Adapters: How to implement HTTPS Adapter by IBM Worklight?
Using compressResponse in Worklight Adapters.
Search for "gzip" in the page.
Basically, in your invokeProcedure:
{
adapter : 'adapter-name',
procedure : 'procedure-name',
parameters : [],
compressResponse : true/false
}

Related

Accessing Soap service using java adapter in mobilefirst

I have written a SOAP WSDL application using mobilefirst by:
1) Using the Discover backend services option
2) Writing my own JavaScript adapter code to follow the documentation provided by IBM.
Now my final R&D is to consume this soap service using a java adapter.
I have gone through many StackOverflow topics and samples but I haven't been able to find anything related. Can anyone explain the steps to invoke a SOAP-based webservice request using java adapter?
The following video blog post details the following about Java adapers: https://www.youtube.com/watch?v=cKM5480-6wI
Creating Java Adapter
Understanding Java Adapter structure
Implementing simple sayHello procedure for HTTP GET method
Implementing several procedures for different HTTP methods
Working with various types of request parameters
Using Java code to access MobileFirst server functionality and Java servlet functionality
Debugging Java Adapters
Communicating with a simple backend using using Apache HTTP Client
Leveraging WSDL files and communicating with a SOAP based webservice
Using WLResourceRequest in client applications to communicate with Java Adapters
Using Postman REST client for communicating with Java Adapters
Create HTTP Adapter
In xml add WebService Host and Port in Domain/Port elements
Assemble soapXMLRequest
Use HTTP Invoke to call server
ex.
var input = {
method : 'post',
returnedContentType : 'xml',
headers : {
SOAPAction : SOAP_FULL_URL
},
path : WEBSERVICE_PATH,
body : {
content : soapXMLRequest,
contentType : 'text/xml; charset=utf-8'
}
};
var response = WL.Server.invokeHttp(input);

How to invoke Java adapter from HTTP adapter?

Is there any API to invoke a Java adapter from a HTTP adapter in IBM MobileFirst Platform Foundation 7.0?
I have tried with WL.Server.invokeHttp(input), but received a 404 response. What should be the value for 'path' in the input?
It is currently not possible to directly call a Java adapter from a JavaScript adapter.
You are encouraged to submit a feature request: https://developer.ibm.com/mobilefirstplatform/help
Alternatives:
Implement a JavaScript adapter that invokes Java code. See the tutorial Using Java in JavaScript adapters
Use another JavaScript adater - set the Java adapter as the backend it connects to and call it from the requesting JavaScript adapter
Rough steps to follow:
You have JavaScript adapter A
This adapter calls a procedure in another JavaScript adapter, adapter B (adapter mashup)
JavaScript adapter B will set in its XML the Java adapter properties as the backend (localhost, MFP server port)
Requests from this adapter should then be sent to /the-server-context-root/adapters/the-java-adapter/*
The Java adapter should have its security disabled, otherwise an access token would need to be forwarded in an header from the client in the request
As you can see the second option is less trivial to implement, and is less supported. I would investigate option 1...

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 !

Customize Worklight Adapter URL

I am building an iOS and Android Apps using Worklight Framework, the worklight server will be protected by IBM Security Access Manager (ISAM) SSO, and therefore the Apps can only be reaching the worklight server after passing the Security challenges. I've found some docs about this integration and it works as intended.
But the apps also offers some features that doesn't required login, in which the Security Manager shouldn't intercept the adapter request to worklight server. The only workaround that suggested by IBM is to create a URL mapping junction in ISAM that defines the URLs that can access by public, and those which shall not. for example /worklight/public and /worklight/secured
But the URL pattern for all worklight adapter are /worklight/invoke?adapter=ADAPTER_NAME, so do we have a way to create a customized URL for public and secured adapter, for example:
/worklight/public/invoke
/worklight/secued/invoke
EDIT 1: Worklight Version 6.0
Thanks in advance.
Please mention the version of Worklight you are using.
One way to achieve this is to create and deploy the adapters in two different projects. That way the context root of both the adapters will be different. So, you'll have URLs such as
/Project1/invoke?... and Project2/invoke?... which you can apply to your filters.

Worklight Adapter authentication required

I'm using Worklight 6.0.0.1 which deployed on WebSphere Liberty 8.5.5.0 and I have my Application which using 2 HTTP adapters.
In the first adapter I putted my Login and logout functions (based form authentication).
In the second adapter I putted some others procedures.
So my problem is as bellow :
When I deployed Worklight (.war) on WebSphere and my other WAR file which containing the Webservices on an other server (Tomcat), Things is going good.
But when I deployed the WAR of worklight and the one containing my Webservices on the same server (WebSphere Liberty), things going wrong with the second adapter (the one that doesn't contain the login function). In each invocation procedure in the second Adapter, I get "authentication required" as response.
But when I invoke a procedure in the first adapter, it returns me the right response.
any idea ? I couldn't figure out the problem
I add that I'm calling the same web services in the two adapter.
This is the log I get :
{"status":200,"invocationContext":null,"invocationResult":{"responseID":"64","statusCode":200,"result":{},"errors":["authentication required"],"isSuccessful":true,"statusReason":"OK","responseHeaders":{"Content-Language":"en-US","Transfer-Encoding":"chunked","Date":"Thu, 05 Dec 2013 06:13:15 GMT","Content-Type":"application/json;charset=UTF-8","X-Powered-By":"Servlet/3.0"},"success":0,"totalTime":280,"responseTime":271}}
When you invoke a procedure in your first adapter, does it call the web service?
If not, I'm assuming that only the second adapter is trying to access the web service.
Considering that, I'm guessing your Tomcat server is not securing the web service. Which means that you can access your web service without any authentication.
WAS or Liberty on the other hand could have application security enabled. Which means that if you try to access your web service deployed on WAS or Liberty, you will be prompted for authentication.
As it works with WAS and Tomcat, the issue seems occurring only under Liberty Profile. In this case only the Worklight trace and the Liberty Profile security trace can allow to understand the possible cause of the issue.