2014-11-04 40 views
0

我正在使用worklight 6.2並構建一個黑莓6/7示例應用程序,但我面臨連接問題。Worklight 6.1:與Worklight的連接問題老版本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

請建議,如果有任何正確的文檔與工作燈webwork的項目。

+0

提及什麼是「連接問題」 - 客戶端日誌和服務器日誌 – 2014-11-04 17:20:08

+0

它正在處理worklight預覽,但是當我在設備中運行它時會發出連接問題。 – 2014-11-05 04:28:00

+0

如果worklight服務器沒有連接,那麼將如何從服務器獲取日誌。 – 2014-11-05 04:29:46

回答

0

從評論中寫道,在物理設備中運行應用程序時已解決此問題。此設備通過WiFi連接到運行服務器的同一網絡。

剩餘的問題是在實際在VMWare Fusion內部運行的BlackBerry Simulator中運行應用程序時。

如果該虛擬機無法訪問您的本地網絡,則其內部運行的應用程序也將無法連接到服務器。

建議:

  • 經過VM設置,並確保它是正確的設置來訪問你的本地網絡
  • 您可以通過它裏面打開瀏覽器檢查,看看是否你能夠訪問服務器的Worklight控制檯
相關問題