IBM Worklight application-descriptor.xml configura

2019-08-17 23:51发布

问题:

I would like to add in "worklightServerRootURL" element on application-descriptor.xml to point to the external Worklight Server but i got the error "Invalid content was found starting with element 'worklightServerRootURL'". Please refer below for my configuration on application-descriptor.xml. Anyone know the solution about this error?

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<application xmlns="http://www.worklight.com/application-descriptor" id="MobileTest" platformVersion="6.2.0.00.20140825-1637">
    <displayName>MobileTest</displayName>
    <description>MobileTest</description>
    <author>
        <name>application's author</name>
        <email>application author's e-mail</email>
        <homepage>http://mycompany.com</homepage>
        <copyright>Copyright My Company</copyright>
    </author>
    <mainFile>index.html</mainFile>
    <features/>
    <thumbnailImage>common/images/thumbnail.png</thumbnailImage>
    <android version="1.0">
        <worklightSettings include="false"/>
        <security>
            <encryptWebResources enabled="false"/>
            <testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/>
            <publicSigningKey/>
            <packageName/>
        </security>
    </android>
    <worklightServerRootURL>http://${local.IPAddress}:9080/worklight</worklightServerRootURL>
</application>

Thank you.

回答1:

The worklightServerRootURL element in application-descriptor.xml is deprecated since Worklight 6.0.0.0 and should not be used, especially not in Worklight 6.2.

In order to have the built application point to a different, remote, Worklight Server you need to right-click on the application folder and select Run As > Build Settings and Remote Target.

In the opened wizard window, you enter the server URL of the remote server. This value will be used in the generated projects and the built app will attempt connecting to that address.

After you enter the path, click OK and then select Run As > Run on Worklight Development Server.

For more information do read the Worklight 6.2

  • Training modules and
  • User documentation topic for the Build Settings and Deploy Target command


回答2:

You can use worklight.properties to manage the endpoint of your worklight server. It is located in the server/conf directory. Inside here look for the line :

publicWorkLightHostname=localhost
# http or https
publicWorkLightProtocol=http
# For default port leave empty
publicWorkLightPort=10080

By changing this setting to the endpoint you want when you build your application the endpoint will be cooked into the app. Also, bare in mind you have

<worklightSettings include="false"/> 

By changing this to true you enable the developer settings on the app which allows you to point the app to different server locations post build. This is a very convenient feature for debugging the app against different end points