4

When configuring WL HTTP Adapters, the domain and port are part of the adapter configuration .xml file build and uploaded on the WL server. For our use case (especially beta testing and demos) the endpoint server url needs to be configurable for the end user. Example, same builds are tested by QA on test envs, while BA connects to demo. We have only one WL Server up and setting environment specific servers is not an option.

Is it possible to change domain/hostname dynamically at application launch or runtime ? Ideally it would be to get and use the domain/hostname value from a drop down or free input from the client and use it.

<connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>{hostname}</domain>
            <port>80</port>         
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="2" />
    </connectivity>
DannySSS
  • 57
  • 4

4 Answers4

4

Update: This answer is useful, so I leave it here for reference, but accept that it doesn't correctly answer this question!

There is a specific Worklight feature designed to address your scenario (for the Infocenter detail, see here).

You can do this by using a combination of worklight.properties and JNDI properties.

For example, let's say you had this setup in your adapter XML:

 <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>${my.adapter.protocol}</protocol>
            <domain>${my.adapter.domain}</domain>
            <port>${my.adapter.port}</port>         
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="2" />
 </connectivity>

You then define default values for these in your worklight.properties file (in the server/conf directory of your Worklight project, and "burnt in" to the .WAR file when you build it):

my.adapter.protocol=http
my.adapter.domain=some.host.com
my.adapter.port=80

You can then override these values in individual environments, by setting JNDI properties. For example, if you are using WebSphere Liberty, you might put this in your server.xml:

<jndiEntry jndiName="my.adapter.protocol" value="https"/>
<jndiEntry jndiName="my.adapter.domain" value="some.other.host.com"/>
<jndiEntry jndiName="my.adapter.port" value="8080"/>
Andrew Ferrier
  • 16,664
  • 13
  • 47
  • 76
  • But the question says that there will be only 1 server and it is required for the adapter to point to different locations; I do not believe this actually answers the question, then. – Idan Adar Aug 06 '14 at 11:34
  • Sorry, you're quite right, I missed that bit of the question. The other answer linked to below is then what I'd recommend. – Andrew Ferrier Aug 06 '14 at 11:45
  • It doesn't address original question, this is still a useful example of how to externalize the Adapter endpoints. Fixed XML to reflect the variables need $ prefix i.e. ${my.adapter.port} – kwv Nov 05 '14 at 20:27
3

You could create 3 adapters: 2 adapters connect to each backend servers, and one "proxy" adapter.

Your application would call the proxy adapter, passing some variable (the dropdown). Then the proxy would call one of the 2 real adapters.

Nathan H
  • 48,033
  • 60
  • 165
  • 247
0

You can´t. An option is to use MashUps.

See:

The idea is to have an Adapter responding to app mobile than this adapter call other deployed adapter (QA, Test Env, Prod Env, etc) considering any logic.

Community
  • 1
  • 1
Rafael Leonhardt
  • 404
  • 5
  • 15
0

I think if you override WL.Server.invokeHttp so you can specify the domain name in each request instead of using the one set in the XML file, would a good alternative . You can get the domain name as parameter in the invocation request.

There is question that may interest you regarding that, you should check it because I'm not sure if it's possible or not. Worklight Adapter Override Origin of request

Community
  • 1
  • 1
ghost rider3
  • 448
  • 1
  • 5
  • 17