0

Worklight 5.0.6.1

We are having a specific requirement from our client about using a PCI Appliance from Intel (http://info.intel.com/rs/intel/images/Intel_Expressway_Tokenization_Broker.pdf) to avoid a PCI Audit for the application and server.

Therefore, the Adapter calls that have something to do with payment data would need to go through this hardware appliance before hitting the worklight server. All other adapter calls should go to the worklight server directly (to not overload the appliance). The idea is to have two different URLs but the same worklight server in the background. It is assumed that the calls through the appliance will be transparent for the worklight server, so worklight functionality should not be impacted.

My questions around this would be:

  • a Worklight best-practice for having two different URLs for the same worklight server and alternating those URLs from the client for Adapter invocations (only; not direct update or anything else, since we assume this is executed native)?

  • is it possible to dynamically overwrite the worklight server URL that is used for an adapter invocation through JavaScript code in the client code? e.g. overwrite a specific JS function that gets/returns the worklight URL from somewhere before the WL.Client AJAX adapter invocation?

We are also looking into having a load-balancer switch the route based on a regex of the AdapterName that is being invoked or so. But it is not sure right now if that is possible and what the performance impact is.

christianmenkens
  • 790
  • 4
  • 22
  • Christian, I do believe you have already asked several times about changing the connection details for an adapter during runtime? the answer did not change since. You cannot change the destination of an adapter request after you have deployed that adapter to the server. – Idan Adar Aug 15 '13 at 18:15
  • yes, I did once, but this is something different. It is not the Adapter connection to the backend. It is the Client invocation to the Wl Server Adapter. All on client side - nothing on server side. We are looking for pointers to where we could look in the WL.Client JS codebase to overwrite the Server domain/port WL.Client.invokeProcedure uses. – christianmenkens Aug 15 '13 at 18:20

3 Answers3

3

Though possible, this is not something supported by WL. You will not be able to get help from support in case something goes wrong (and it will). You have to keep in mind that all server cookies (e.g. session id) are per domain. Therefore when you're dynamically changing server URL you will loose them. Therefore WL server will treat your request as a new session, unrelated to an old (existing) one. This is not something specific to WL, this is how HTTP works.

WL keeps server URLs in two global properties - WL.AppProp.WORKLIGHT_ROOT_URL and WL.AppProp.APP_SERVICES_URL. You can override them thus changing server URLs.

First one is used for all requests triggered by developer (init, connect, login etc). Second one is used for miscellaneous internal functionality (e.g. encrypted cache).

Once again - this is a hack, definitely not a solution. Use with caution if at all:)

Anton
  • 3,166
  • 1
  • 13
  • 12
  • Thank you for your quick answer. We can see how we can read it through WL.Client.getAppProperty, but how would you suggest to overwrite such a property? It does not seem to exist as a global JS property that can just be set to a new value in JS code. So we would need to overwrite the getAppProperty function? Is the WL ajax call using this function to get the right URL before the call? – christianmenkens Aug 27 '13 at 16:25
  • just override the original property. E.g: WL.AppProp.WORKLIGHT_ROOT_URL = "http://some-other-server.com:9080"; – Anton Aug 27 '13 at 20:28
  • Ok. we will try, thank you. just thought that since WL.Logger.log( WL.AppProp.WORKLIGHT_ROOT_URL) does not return/print the property to the console, it is not a global property that can just be easily overwritten but that WL.Client.getAppProperty does some other "magic" to get the property from somewhere. – christianmenkens Aug 27 '13 at 22:05
  • In reference to the part of my question about the load-balancer routing mechanism. An option that came up is to add a custom Header to the AJAX call from the client to the adapter. Is that somehow possible and maybe supported by WL? I know the documentation for the HTTPAdapter where you can do that. – christianmenkens Aug 29 '13 at 19:53
  • 1
    You can add/remove global headers on client side. http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp?topic=%2Fcom.ibm.worklight.help.doc%2Fapiref%2Fr_wl_client_addglobalheader.html – Anton Aug 30 '13 at 07:54
0

How About this,if we define our own function that will call some static properties and update them ?

function changeServerUrl(serverURL) {

WL.StaticAppProps.APP_SERVICES_URL = serverURL + WL.StaticAppProps.POSTFIX_APP_SERVICES_URL; WL.StaticAppProps.WORKLIGHT_ROOT_URL = serverURL + WL.StaticAppProps.POSTFIX_WORKLIGHT_ROOT_URL; WL.StaticAppProps.WORKLIGHT_BASE_URL = serverURL; }

and call it

chnageServerUrl("http://"+yourServerIP+":"+PORT);

nouman
  • 11
  • 1
  • Not supported. Anything that you do regarding server changing, is NOT supported. If you want support for this, using MFP 6.3, which now includes public API to change sever URL. – Idan Adar Jan 22 '15 at 05:07
-2

if you dig into the worklight.js file there is a function "setWLUrl(url)" that can be use to change the serevr URL. call it like this and its done

setWLUrl("http://"+yourServerIP+":PORT");

its kind a hack but i think it should not have anny issue since its a function within there api.

Good Luck

nouman
  • 11
  • 1