IBM Worklight - How to change dynamically domain/hostname to which the adapter connects from the client at launch or runtime?

后端 未结 4 1204
耶瑟儿~
耶瑟儿~ 2020-12-11 08:25

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

相关标签:
4条回答
  • 2020-12-11 08:57

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

    See:

    • IBM Worklight 6.1 - Can a HTTP adapter call another HTTP adapter on server-side?

    • http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v620/04_11_Advanced_adapter_usage_and_mashup.pdf

    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.

    0 讨论(0)
  • 2020-12-11 09:07

    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.

    0 讨论(0)
  • 2020-12-11 09:11

    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"/>
    
    0 讨论(0)
  • 2020-12-11 09:15

    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

    0 讨论(0)
提交回复
热议问题