IBM Worklight 6.0 - 使用 Web 服务的混合应用程序无法在实际设备上运行?

Posted

技术标签:

【中文标题】IBM Worklight 6.0 - 使用 Web 服务的混合应用程序无法在实际设备上运行?【英文标题】:IBM Worklight 6.0 - Hybrid application using webservices is not working on actual device? 【发布时间】:2013-07-24 05:27:43 【问题描述】:

我使用 Dojo 1.9 开发了一个应用程序。 在其中,我尝试使用 HTTP 适配器从 SOAP Web 服务中获取数据。

在 Worklight Console 的 MBS 中预览应用程序时在 Build All 和 Deploy 之后运行良好(参见下面的屏幕截图 #1),与在 android 2.2 AVD 上相同(参见屏幕截图 #2)。

实际设备上运行应用程序时,它总是返回“请求失败!”

有没有办法让它在连接到另一个网络的实际设备上工作?

我是否错过了在 impl.js 文件中创建 SOAP 消息?

是否有必要进行 SOAP 请求调用?

如果是,请告诉我如何生成 SOAP 消息?

适配器 BseNsePrice-impl.js:

function BSENSEPrice(Exchng) 
    var path = 'ClientStockService.asmx/BSENSEPrice';

    var input = 
        method : 'get',
        returnedContentType : 'text/xml; charset=utf-8',
        path : path,
        parameters: 'Exchng': Exchng 
    ;

    return WL.Server.invokeHttp(input);


应用 JavaScript:

function wlCommonInit()
    require([ "layers/core-web-layer", "layers/mobile-ui-layer" ], dojoInit);



function dojoInit() 
    require([ "dojo/ready", "dojo/parser", "dojox/mobile", "dojo/dom", "dijit/registry", "dojox/mobile/ScrollableView", "dojox/mobile/Heading", "dojox/mobile/RoundRectList", "dojox/mobile/ListItem", "dojox/mobile/View", "dojox/mobile/Container", "dojox/mobile/ContentPane", "dojox/mobile/TabBar", "dojox/mobile/TabBarButton" ], function(ready) 
        ready(function() 
        );
    );



function mobBSENSEPrice(Exchng) 
       var invocationData = 
               adapter : 'BSENSEPrice',
               procedure : 'BSENSEPrice',
               parameters : []
           ;

       WL.Client.invokeProcedure(invocationData,
           onSuccess : mobBSENSEPriceSuccess,
           onFailure : mobBSENSEPriceFailure,
       );
   ;

 function mobBSENSEPriceSuccess(result) 
       var httpStatusCode = result.status;
       var div = $("#invokeResult");
       /*var span = $("#value");*/
       if (200 == httpStatusCode) 
           var invocationResult = result.invocationResult;
           var isSuccessful = invocationResult.isSuccessful;
           if (true == isSuccessful) 

               var data = invocationResult.DataSet.diffgram.NewDataSet.Table;
               for (var i=0;i<data.length;i++)
               
                div.append(data[i].SYMBOL);
                div.append('<br>');
                div.append(data[i].PRICE);
                div.append('<br>');
                div.append('<strong>Change:</strong> ' + data[i].PER_CHANGE);
                div.append('<br>');
                div.append('<strong>Change(%) :</strong> ' + data[i].ChangePer);
                div.append('<br>');
                div.append('<br>');
               
           
           else 
               div.append("Request Failed....!");
                               
       
       else 
           div.append("Request Failed!");
       
   

  function mobBSENSEPriceFailure(result)
            var div = $("#invokeResult");
        div.append("Request Failed!");
   

LogCat:

07-24 11:27:08.227: I/dalvikvm(326): Could not find method org.apache.cordova.CordovaWebView.setOverScrollMode, referenced from method org.apache.cordova.DroidGap.init
07-24 11:27:08.227: W/dalvikvm(326): VFY: unable to resolve virtual method 12024: Lorg/apache/cordova/CordovaWebView;.setOverScrollMode (I)V
07-24 11:27:08.227: D/dalvikvm(326): VFY: replacing opcode 0x6e at 0x0043
07-24 11:27:08.267: I/CordovaLog(326): Changing log level to DEBUG(3)
07-24 11:27:08.277: I/CordovaLog(326): Found preference for exit-on-suspend=false
07-24 11:27:08.277: D/CordovaLog(326): Found preference for exit-on-suspend=false
07-24 11:27:08.277: D/DroidGap(326): DroidGap.onCreate()
07-24 11:27:08.317: I/dalvikvm(326): Could not find method android.webkit.WebView.<init>, referenced from method org.apache.cordova.CordovaWebView.<init>
07-24 11:27:08.317: W/dalvikvm(326): VFY: unable to resolve direct method 536: Landroid/webkit/WebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
07-24 11:27:08.317: D/dalvikvm(326): VFY: replacing opcode 0x70 at 0x0001
07-24 11:27:08.317: D/dalvikvm(326): VFY: dead code 0x0004-0046 in Lorg/apache/cordova/CordovaWebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
07-24 11:27:08.737: D/JsMessageQueue(326): Set native->JS mode to 2
07-24 11:27:08.737: I/CordovaWebView(326): Disabled addjavascriptInterface() bridge since Android version is old.
07-24 11:27:08.767: E/dalvikvm(326): Could not find class 'android.webkit.WebResourceResponse', referenced from method org.apache.cordova.CordovaWebViewClient.getWhitelistResponse
07-24 11:27:08.767: W/dalvikvm(326): VFY: unable to resolve new-instance 176 (Landroid/webkit/WebResourceResponse;) in Lorg/apache/cordova/CordovaWebViewClient;
07-24 11:27:08.767: D/dalvikvm(326): VFY: replacing opcode 0x22 at 0x000b
07-24 11:27:08.767: D/dalvikvm(326): VFY: dead code 0x000d-0014 in Lorg/apache/cordova/CordovaWebViewClient;.getWhitelistResponse ()Landroid/webkit/WebResourceResponse;
07-24 11:27:08.777: W/dalvikvm(326): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)
07-24 11:27:08.777: W/dalvikvm(326): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)
07-24 11:27:08.777: W/dalvikvm(326): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)
07-24 11:27:08.797: D/DroidGap(326): DroidGap.init()
07-24 11:27:08.937: I/UICAndroid(326): LoggingLevel=3, AddCookieDomain=false, PostMessageTimeout=60000, CookiePath=/, CookieParam=, KillSwitchTimeInterval=180, BufferPercent=20, HasToPersistLocalCache=true , MessageTypeHeader=WorklightHit, CookieDomain=, WhiteListParam=id, LibraryVersion=8.8.1.0, MaskIdList=com.tealeaf.sp:id/EditText*,com.tealeaf.sp:id/login.password, PostMessageLevelWiFi=3, UseRandomSample=false, KillSwitchMaxNumberOfTries=3, SensitiveCapitalCaseAlphabet=X, FilterMessageTypes=true, PostMessageTimeIntervals=30, SensitiveSmallCaseAlphabet=x, CompressPostMessage=true, PostMessageMaxBytesSize=20000, SensitiveSymbol=#, PostMessageLevelCellular=3, MessageTypes=4,5,6, PostMessageSocketTimeout=60000, CookieUrl=, UseWhiteList=true, KillSwitchUrl=, KillSwitchEnabled=false, MessageVersion=2.1.0.0, HasMasking=true, TimeIntervalBetweenSnapshots=60, PostMessageUrl=@USE_WORKLIGHT_DEFAULT@, CachedFileMaxBytesSize=512000, BufferLimit=100, AddCookiePath=false, SensitiveNumber=9, CachingLevel=3, ManualPostEnabled=true, HasCustomMask=true, DisplayLogging=true, MaxStringsLength=300, AddMessageTypeHeader=true, RandomSampleParam=, DoPostOnIntervals=false
07-24 11:27:09.118: D/dalvikvm(326): GC_FOR_MALLOC freed 3477 objects / 255912 bytes in 101ms
07-24 11:27:09.257: I/UICAndroid(326): Screen height:420  Screen width780
07-24 11:27:09.317: D/DroidGap(326): Resuming the App
07-24 11:27:09.327: D/WLDroidGap(326): New installation/upgrade detected, copying resources and saving new checksum
07-24 11:27:09.417: I/UICAndroid(326): Network changed
07-24 11:27:09.447: D/SoftKeyboardDetect(326): Ignore this event
07-24 11:27:09.567: D/SoftKeyboardDetect(326): Ignore this event
07-24 11:27:09.698: D/WLDroidGap(326): Started copying files to local storage...
07-24 11:27:09.987: I/UICAndroid(326): Did Client State change?: true
07-24 11:27:13.757: D/dalvikvm(326): GC_FOR_MALLOC freed 3411 objects / 478752 bytes in 54ms
07-24 11:27:14.618: D/dalvikvm(326): GC_FOR_MALLOC freed 1944 objects / 461952 bytes in 52ms
07-24 11:27:17.138: D/dalvikvm(326): GC_FOR_MALLOC freed 1855 objects / 468928 bytes in 73ms
07-24 11:27:19.058: D/dalvikvm(326): GC_FOR_MALLOC freed 2204 objects / 516816 bytes in 57ms
07-24 11:27:20.668: D/dalvikvm(326): GC_FOR_MALLOC freed 2098 objects / 483856 bytes in 50ms
07-24 11:27:21.418: D/dalvikvm(326): GC_FOR_MALLOC freed 1791 objects / 472968 bytes in 56ms
07-24 11:27:22.998: D/dalvikvm(326): GC_FOR_MALLOC freed 2105 objects / 498800 bytes in 55ms
07-24 11:27:24.683: D/dalvikvm(326): GC_FOR_MALLOC freed 2203 objects / 512160 bytes in 74ms
07-24 11:27:28.677: D/WLDroidGap(326): Finished copying files to local storage...
07-24 11:27:28.709: D/WLDroidGap(326): no need to check web resource integrity
07-24 11:27:28.797: D/dalvikvm(326): GC_FOR_MALLOC freed 2474 objects / 524672 bytes in 90ms
07-24 11:27:28.877: D/CordovaWebView(326): >>> loadUrl(file:///data/data/com.Accordfintech/files/www/skinLoader.html)
07-24 11:27:28.892: D/PluginManager(326): init()
07-24 11:27:28.907: D/CordovaWebView(326): >>> loadUrlNow()
07-24 11:27:28.977: D/DroidGap(326): onMessage(onPageStarted,file:///data/data/com.Accordfintech/files/www/skinLoader.html)
07-24 11:27:30.067: D/Cordova(326): onPageFinished(file:///data/data/com.Accordfintech/files/www/skinLoader.html)
07-24 11:27:30.067: D/Cordova(326): Trying to fire onNativeReady
07-24 11:27:30.067: D/DroidGap(326): onMessage(onNativeReady,null)
07-24 11:27:30.067: D/DroidGap(326): onMessage(onPageFinished,file:///data/data/com.Accordfintech/files/www/skinLoader.html)
07-24 11:27:30.837: D/CordovaLog(326): Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only.
07-24 11:27:30.837: I/Web Console(326): Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. at file:///data/data/com.Accordfintech/files/www/default/wlclient/js/cordova.js:908
07-24 11:27:30.937: D/CordovaNetworkManager(326): Connection Type: 3g
07-24 11:27:30.937: D/CordovaNetworkManager(326): Connection Type: 3g
07-24 11:27:30.937: D/DroidGap(326): onMessage(networkconnection,3g)
07-24 11:27:30.977: D/DroidGap(326): onMessage(spinner,stop)
07-24 11:27:31.177: D/dalvikvm(326): GC_FOR_MALLOC freed 2179 objects / 213704 bytes in 137ms
07-24 11:27:31.267: D/CordovaWebView(326): >>> loadUrl(file:///data/data/com.Accordfintech/files/www/default/Accordfintech.html)
07-24 11:27:31.267: D/PluginManager(326): init()
07-24 11:27:31.277: D/CordovaWebView(326): >>> loadUrlNow()
07-24 11:27:31.318: D/DroidGap(326): onMessage(onPageStarted,file:///data/data/com.Accordfintech/files/www/default/Accordfintech.html)
07-24 11:27:31.597: D/dalvikvm(326): GC_FOR_MALLOC freed 3136 objects / 267808 bytes in 65ms
07-24 11:27:31.817: D/dalvikvm(326): GC_FOR_MALLOC freed 1006 objects / 173440 bytes in 101ms
07-24 11:27:32.087: D/DroidGap(326): onMessage(spinner,stop)
07-24 11:27:40.138: D/Cordova(326): onPageFinished(file:///data/data/com.Accordfintech/files/www/default/Accordfintech.html)
07-24 11:27:40.148: D/Cordova(326): Trying to fire onNativeReady
07-24 11:27:40.148: D/DroidGap(326): onMessage(onNativeReady,null)
07-24 11:27:40.148: D/DroidGap(326): onMessage(onPageFinished,file:///data/data/com.Accordfintech/files/www/default/Accordfintech.html)
07-24 11:27:40.898: D/CordovaLog(326): Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only.
07-24 11:27:40.898: I/Web Console(326): Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. at file:///data/data/com.Accordfintech/files/www/default/wlclient/js/cordova.js:908
07-24 11:27:40.958: D/CordovaNetworkManager(326): Connection Type: 3g
07-24 11:27:40.988: D/CordovaNetworkManager(326): Connection Type: 3g
07-24 11:27:40.988: D/DroidGap(326): onMessage(networkconnection,3g)
07-24 11:27:41.018: D/DroidGap(326): onMessage(spinner,stop)
07-24 11:27:41.198: I/dalvikvm(326): Could not find method java.util.Calendar.getDisplayNames, referenced from method org.apache.cordova.Globalization.getDateNames
07-24 11:27:41.198: W/dalvikvm(326): VFY: unable to resolve virtual method 10795: Ljava/util/Calendar;.getDisplayNames (IILjava/util/Locale;)Ljava/util/Map;
07-24 11:27:41.198: D/dalvikvm(326): VFY: replacing opcode 0x74 at 0x009d
07-24 11:27:41.198: I/dalvikvm(326): Could not find method java.util.Calendar.getDisplayNames, referenced from method org.apache.cordova.Globalization.getDateNames
07-24 11:27:41.198: W/dalvikvm(326): VFY: unable to resolve virtual method 10795: Ljava/util/Calendar;.getDisplayNames (IILjava/util/Locale;)Ljava/util/Map;
07-24 11:27:41.198: D/dalvikvm(326): VFY: replacing opcode 0x74 at 0x00d0
07-24 11:27:41.198: I/dalvikvm(326): Could not find method java.util.Calendar.getDisplayNames, referenced from method org.apache.cordova.Globalization.getDateNames
07-24 11:27:41.198: W/dalvikvm(326): VFY: unable to resolve virtual method 10795: Ljava/util/Calendar;.getDisplayNames (IILjava/util/Locale;)Ljava/util/Map;
07-24 11:27:41.198: D/dalvikvm(326): VFY: replacing opcode 0x74 at 0x00e3
07-24 11:27:41.198: I/dalvikvm(326): Could not find method java.util.Calendar.getDisplayNames, referenced from method org.apache.cordova.Globalization.getDateNames
07-24 11:27:41.198: W/dalvikvm(326): VFY: unable to resolve virtual method 10795: Ljava/util/Calendar;.getDisplayNames (IILjava/util/Locale;)Ljava/util/Map;
07-24 11:27:41.198: D/dalvikvm(326): VFY: replacing opcode 0x74 at 0x00f2
07-24 11:27:41.198: D/dalvikvm(326): VFY: dead code 0x00a0-00b8 in Lorg/apache/cordova/Globalization;.getDateNames (Lorg/json/JSONArray;)Lorg/json/JSONObject;
07-24 11:27:41.198: D/dalvikvm(326): VFY: dead code 0x00d3-00d4 in Lorg/apache/cordova/Globalization;.getDateNames (Lorg/json/JSONArray;)Lorg/json/JSONObject;
07-24 11:27:41.198: D/dalvikvm(326): VFY: dead code 0x00e6-00e7 in Lorg/apache/cordova/Globalization;.getDateNames (Lorg/json/JSONArray;)Lorg/json/JSONObject;
07-24 11:27:41.198: D/dalvikvm(326): VFY: dead code 0x00f5-0118 in Lorg/apache/cordova/Globalization;.getDateNames (Lorg/json/JSONArray;)Lorg/json/JSONObject;
07-24 11:27:41.388: D/Accordfintech(326): wlclient init started
07-24 11:27:41.428: D/Accordfintech(326): Read cookies: null
07-24 11:27:41.428: D/Accordfintech(326): CookieMgr read cookies: 
07-24 11:27:41.618: D/dalvikvm(326): GC_FOR_MALLOC freed 5221 objects / 855328 bytes in 82ms
07-24 11:27:41.928: D/Accordfintech(326): before: app init onSuccess
07-24 11:27:42.018: D/Accordfintech(326): after: app init onSuccess
07-24 11:27:42.018: D/Accordfintech(326): added onPause event handler 
07-24 11:27:42.028: D/Accordfintech(326): wlclient init success
07-24 11:27:59.578: D/Accordfintech(326): Request [http://10.20.50.244:10080/Accord/apps/services/api/Accordfintech/android/query]
07-24 11:28:00.369: D/dalvikvm(326): GC_FOR_MALLOC freed 7040 objects / 435712 bytes in 63ms
07-24 11:28:00.629: D/Accordfintech(326): Request [http://10.20.50.244:10080/Accord/apps/services/api/Accordfintech/android/query]
07-24 11:28:00.698: D/Accordfintech(326): Request [http://10.20.50.244:10080/Accord/apps/services/api/Accordfintech/android/query]
07-24 11:28:01.038: D/Accordfintech(326): response [http://10.20.50.244:10080/Accord/apps/services/api/Accordfintech/android/query] success: /*-secure-
07-24 11:28:01.038: D/Accordfintech(326): "responseID":"2","statusCode":200,"errors":[],"isSuccessful":true,"statusReason":"OK","WL-Authentication-Success":"wl_remoteDisableRealm":"userId":"null","attributes":,"isUserAuthenticated":1,"displayName":"null","wl_antiXSRFRealm":"userId":"88cgj8s4m26caj0vstt6imlief","attributes":,"isUserAuthenticated":1,"displayName":"88cgj8s4m26caj0vstt6imlief","wl_deviceNoProvisioningRealm":"userId":"cf95dc53-f383-39a8-b6fd-749f3ef439cd","attributes":"mobileClientData":"com.worklight.core.auth.ext.MobileClientData@59727ed4","isUserAuthenticated":1,"displayName":"cf95dc53-f383-39a8-b6fd-749f3ef439cd","wl_anonymousUserRealm":"userId":"587f3a3b-148c-492a-9fa5-7bdbb8b9e046","attributes":,"isUserAuthenticated":1,"displayName":"587f3a3b-148c-492a-9fa5-7bdbb8b9e046","DataSet":"schema":"id":"NewDataSet","element":"complexType":"choice":"element":"complexType":"sequence":"element":["name":"SYMBOL","type":"xs:string","minOccurs":"0","name":"PRICE","type":"xs:decimal","minOccurs":"0","name":"PER_CHANGE","type":"xs:decimal","minOccurs":"0","name":"ChangePer","type":"xs:decimal","minOccurs":"0","name":"PREV_CLOSE","type":"xs:decimal","minOccurs":"0","name":"Open","type":"xs:decimal","minOccurs":"0","name":"UPD_TIME","type":"xs:string","minOccurs":"0","name":"Trend","type":"xs:string","minOccurs":"0","name":"high","type":"xs:double","minOccurs":"0","name":"low","type":"xs:double","minOccurs":"0"],"name":"Table","maxOccurs":"unbounded","minOccurs":"0","name":"NewDataSet","IsDataSet":"true","UseCurrentLocale":"true","msdata":"urn:schemas-microsoft-com:xml-msdata","xs":"http:\/\/www.w3.org\/2001\/XMLSchema","xmlns":"","xmlns":"http:\/\/ACEwebservice\/","diffgram":"NewDataSet":"Table":["id":"Table1","Open":"20200.20","PRICE":"20041.68","PREV_CLOSE":"20302.13","PER_CHANGE":"-260.45","SYMBOL":"SENSEX","ChangePer":"-1.28","high":"20252.7","low":"20018.32","rowOrder":"0","Trend":"-","UPD_TIME":"24-Jul-2013 11:25","id":"Table2","Open":"6032.20","PRICE":"5974.95","PREV_CLOSE":"6077.80","PER_CHANGE":"-102.85","SYMBOL":"NIFTY","ChangePer":"-1.69","high":"6047.25","low":"5968.4","rowOrder":"1","Trend":"-","UPD_TIME":"24-Jul-2013 11:15"],"xmlns":"","msdata":"urn:schemas-microsoft-com:xml-msdata","diffgr":"urn:schemas-microsoft-com:xml-diffgram-v1","responseHeaders":"X-AspNet-Version":"2.0.50727","Date":"Wed, 24 Jul 2013 06:00:48 GMT","Content-Length":"2480","Expires":"-1","Content-Type":"text\/xml; charset=utf-8","Server":"Microsoft-IIS\/6.0","X-Powered-By":"ASP.NET","Cache-Control":"no-cache","Pragma":"no-cache","warnings":[],"totalTime":140,"responseTime":139,"info":[]*/
07-24 11:28:01.268: D/Accordfintech(326): response [http://10.20.50.244:10080/Accord/apps/services/api/Accordfintech/android/query] success: /*-secure-
07-24 11:28:01.268: D/Accordfintech(326): "responseID":"3","statusCode":200,"errors":[],"isSuccessful":true,"statusReason":"OK","DataSet":"schema":"id":"NewDataSet","element":"complexType":"choice":"element":"complexType":"sequence":"element":["name":"SYMBOL","type":"xs:string","minOccurs":"0","name":"PRICE","type":"xs:decimal","minOccurs":"0","name":"PER_CHANGE","type":"xs:decimal","minOccurs":"0","name":"ChangePer","type":"xs:decimal","minOccurs":"0","name":"PREV_CLOSE","type":"xs:decimal","minOccurs":"0","name":"Open","type":"xs:decimal","minOccurs":"0","name":"UPD_TIME","type":"xs:string","minOccurs":"0","name":"Trend","type":"xs:string","minOccurs":"0","name":"high","type":"xs:double","minOccurs":"0","name":"low","type":"xs:double","minOccurs":"0"],"name":"Table","maxOccurs":"unbounded","minOccurs":"0","name":"NewDataSet","IsDataSet":"true","UseCurrentLocale":"true","msdata":"urn:schemas-microsoft-com:xml-msdata","xs":"http:\/\/www.w3.org\/2001\/XMLSchema","xmlns":"","xmlns":"http:\/\/ACEwebservice\/","diffgram":"NewDataSet":"Table":["id":"Table1","Open":"20200.20","PRICE":"20041.68","PREV_CLOSE":"20302.13","PER_CHANGE":"-260.45","SYMBOL":"SENSEX","ChangePer":"-1.28","high":"20252.7","low":"20018.32","rowOrder":"0","Trend":"-","UPD_TIME":"24-Jul-2013 11:25","id":"Table2","Open":"6032.20","PRICE":"5974.95","PREV_CLOSE":"6077.80","PER_CHANGE":"-102.85","SYMBOL":"NIFTY","ChangePer":"-1.69","high":"6047.25","low":"5968.4","rowOrder":"1","Trend":"-","UPD_TIME":"24-Jul-2013 11:15"],"xmlns":"","msdata":"urn:schemas-microsoft-com:xml-msdata","diffgr":"urn:schemas-microsoft-com:xml-diffgram-v1","responseHeaders":"X-AspNet-Version":"2.0.50727","Date":"Wed, 24 Jul 2013 06:00:48 GMT","Content-Length":"2480","Expires":"-1","Content-Type":"text\/xml; charset=utf-8","Server":"Microsoft-IIS\/6.0","X-Powered-By":"ASP.NET","Cache-Control":"no-cache","Pragma":"no-cache","warnings":[],"totalTime":181,"responseTime":180,"info":[]*/

屏幕截图 #1 - Worklight 控制台 MBS:

屏幕截图 #2 - Android 2.2。 AVD:

【问题讨论】:

你看看Logcat有什么问题吗?或者你可以把你的logcat贴在这里??? 将 LogCat 输出添加到您的问题中。还将您的实现添加到问题中。 它在 avd 上可以正常工作,但不能在实际设备上工作? 能否请您添加您被要求提供的信息? 用您需要的所有详细信息编辑了我的问题。如果我遗漏了什么,请告诉我? 【参考方案1】:

如果您的应用程序无法连接到 Worklight 服务器,适配器过程也会失败。部署到真实设备时,请确保通过在“全部构建并部署”之后运行“为远程服务器构建”来明确指定 Worklight 服务器的 IP 地址。默认情况下,“全部构建并部署”将使用 localhost 来定位 Worklight 服务器,这将导致真实设备上的连接错误。

要验证您的连接失败是由于服务器地址不正确造成的,请使用硬件菜单按钮在您的应用程序打开时调出 Worklight 设置菜单。从那里检查“更改服务器 url”框并确保下面的 url 以 Worklight 服务器的 IP 地址为目标。

【讨论】:

以上是关于IBM Worklight 6.0 - 使用 Web 服务的混合应用程序无法在实际设备上运行?的主要内容,如果未能解决你的问题,请参考以下文章

IBM Worklight 6.0 - 移动浏览器模拟器是不是支持 Worklight 皮肤?

IBM Worklight 6.0 - 添加 Worklight 文件条目选项时遇到问题

IBM Worklight 6.0 - 内容根目录和本地 Worklight 服务器设置

IBM Worklight 6.0 - BlackBerry 10 中的 window.open() 失败

IBM Worklight 6.0 - 控制 Dojo 层

IBM Worklight 6.0 - 访问 Worklight Server 时出错