Worklight 6.1:与BB old 6/7的工作灯连接问题

时间:2014-11-04 14:31:57

标签: ibm-mobilefirst worklight-runtime

我正在使用worklight 6.2并构建一个黑莓6/7示例应用程序,但我面临连接问题。

由于连接问题,我无法调用适配器,每次因为适配器响应而导致失败。

我的代码段在下面给出

config.xml中

<widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0" rim:backButton="exit">  
    <name>bb67</name>  
    <description>bb67</description>  
    <author email="application author's e-mail">application's author</author>  
    <feature id="worklightFeature" required="false" version="1.0.0"/>  
    <feature id="blackberry.ui.dialog" version="1.0.0"/>  
    <feature id="blackberry.ui.menu" version="1.0.0"/>  
    <feature id="blackberry.invoke" version="1.0.0"/>  
    <feature id="blackberry.invoke.BrowserArguments" version="1.0.0"/>  
    <feature id="blackberry.identity" version="1.0.0"/>  
    <feature id="blackberry.app" version="1.0.0"/>  
    <feature id="blackberry.app.event" version="1.0.0"/>  
    <access subdomains="true" uri="*"/>  
    <content src="www/skinLoader.html"/>  
    <icon rim:hover="false" src="icon.png"/>  
    <rim:loadingScreen backgroundImage="" foregroundImage="splash.png" onLocalPageLoad="false" onFirstLaunch="true"/> 
</widget>

索引,HTML

<!DOCTYPE HTML><html>
    <head>
        <meta charset="UTF-8">
        <title>bb67</title>
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" name="viewport">
            <!--
                <link rel="shortcut icon" href="images/favicon.png">
                <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> 
            -->
        <link href="worklight/worklight.css" rel="stylesheet">
        <link href="css/main.css" rel="stylesheet">
        <script>
        // Define WL namespace.
        var WL = WL ? WL : {};
        /**
         * WLClient configuration variables.
         * Values are injected by the deployer that packs the gadget.
         */
         WL.StaticAppProps = {
   "APP_DISPLAY_NAME": "bb67",
   "APP_ID": "bb67",
   "APP_SERVICES_URL": "http:\/\/192.168.0.222:10080\/bb67\/apps\/services\/",
   "APP_VERSION": "1.0",
   "ENVIRONMENT": "blackberry",
   "LOGIN_DISPLAY_TYPE": "embedded",
   "WORKLIGHT_PLATFORM_VERSION": "6.2.0.01.20141027-1531",
   "WORKLIGHT_ROOT_URL": "http:\/\/192.168.0.222:10080\/bb67\/apps\/services\/api\/bb67\/blackberry\/"
};
</script>
        <script src="worklight/wljq.js"></script>
        <script src="worklight/worklight.js"></script>
        <script>window.$ = window.jQuery = WLJQ;</script>
    </head>
    <body style="display: none;">
            <!--application UI goes here-->
            Hello Worklight<input onclick="msiteCall()" type="button" value="Call Adapter">
            <script src="js/initOptions.js"></script>
            <script src="js/main.js"></script>
            <script src="js/messages.js"></script>
    </body>
</html>

main.js

/* JavaScript content from js/main.js in folder common */
function wlCommonInit(){
    /*
     * Use of WL.Client.connect() API before any connectivity to a Worklight Server is required. 
     * This API should be called only once, before any other WL.Client methods that communicate with the Worklight Server.
     * Don't forget to specify and implement onSuccess and onFailure callback functions for WL.Client.connect(), e.g:
     *    
     *    WL.Client.connect({
     *          onSuccess: onConnectSuccess,
     *          onFailure: onConnectFailure
     *    });
     *     
     */

    // Common initialization code goes here
      WL.Client.connect({
                onSuccess: function onConnectSuccess(res){
                        alert('Connection Success '+res);
                },
                onFailure: function onConnectFailure(res){
                        alert('Connection Failure '+res);
                }
         });
}

/* JavaScript content from js/main.js in folder blackberry */
// This method is invoked after loading the main HTML and successful initialization of the Worklight runtime.
function wlEnvInit(){
    wlCommonInit();
    // Environment initialization code goes here
}
var timeout = 30000;
function msiteCall(){
    alert('Inside call');

    var invocationData = {
            adapter : "msiteAdap",
            procedure : "getStories",
            parameters : [],
            compressResponse : true
    };
    //WL.Logger.debug('invoke msg  '+invocationData, '');
    WL.Client.invokeProcedure(invocationData, {
        onSuccess : function succ(){alert("Success...");},
        onFailure : function fail(){alert("Failure...");},              

    });
}

请提示是否遗漏了任何内容。我正在使用webworks来构建项目。 我使用下面的命令来构建cod文件。

bbwp C:\myapp\myarchive.zip -d -o C:\myapp\output 

以下是来自worklight项目的生成结构。

enter image description here

请在工作灯中建议是否有正确的文档项目。

1 个答案:

答案 0 :(得分:0)

从评论中可以看出,在物理设备中运行应用程序时已经解决了这个问题。此设备通过WiFi连接到运行服务器的同一网络。

剩下的问题是在BlackBerry Simulator中运行应用程序时,该模拟器实际上是在VMWare Fusion中运行的。

如果该VM无法访问您的本地网络,则其中运行的应用程序也将无法连接到服务器。

建议:

  • 完成虚拟机设置并确保正确设置以访问本地网络
  • 您可以通过在其中打开浏览器来检查这一点,看看您是否能够访问服务器的Worklight控制台