0

私のアプリケーションでは、work-light アダプターを介して JSON 応答を取得しています。エミュレーターでは、work-light プロシージャーを呼び出した後にのみ、応答が正しく表示されます。しかし、実際のデバイスで実行すると、応答が表示されませんでした。この問題を解決するのに役立つ人はいますか?

MY アダプター XML コード:

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
5725-G92 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<wl:adapter name="JSON"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">

<displayName>JSON</displayName>
<description>JSON</description>
<connectivity>
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
        <protocol>http</protocol>
        <domain>www.name.in</domain>
        <port>80</port>         
    </connectionPolicy>
    <loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>


<procedure name="getJSONs"> </procedure>
<procedure name="addJSON"> </procedure>
<procedure name="updateJSON"> </procedure>
<procedure name="deleteJSON"> </procedure>

MY アダプター JS コード:

function getJSONs() {

var input = {
    method : 'get',
    returnedContentType : 'json',
    path : 'getMerchantdetails?json=',

};

return WL.Server.invokeHttp(input);
 }

私の主なJSコード

 function wlCommonInit(){

busyIndicator = new WL.BusyIndicator("view0");

// Common initialization code goes here
$("#btn").click(function(){
getJSONs();
});
}

function getJSONs(){
//busyIndicator.show();
  var invocationData =
  {
    adapter    : "JSON",
    procedure  : "getJSONs",
    parameters : []
  };

  WL.Client.invokeProcedure(invocationData,
          {
      onSuccess : merchantdetails,
      //onFailure : mobGmapLatLngFailure,

          });

  function merchantdetails(result) {
      var httpStatusCode = result.status;
        //var div = $("#invokeResult");
        if (200 == httpStatusCode) {
            var invocationResult = result.invocationResult;
            var isSuccessful = invocationResult.isSuccessful;
            if (true == isSuccessful) {
                var result = invocationResult.merchant_detail;

                //alert(result[0].merchant_long_desc+" - "+result[0].merchant_contact_number);
                $("#txt").html(result[0].merchant_long_desc+" - "+result[0].merchant_contact_number);

            } else {
                //div.append("Request Failed!");
            }
        } else {
            //div.append("Request Failed!");
        }
  }
}

私の息子の反応

"merchant_detail": [
  {
     "merchant_code": "1",
     "merchant_contact_number": "2147483647",
     "merchant_logo": "",
     "merchant_long_desc": "Anjappar",
     "merchant_short_desc": "Anjappar",
     "merchant_type_code": "1"
  }
],
4

1 に答える 1

2

どのバージョンのワークライトを使用していますか? 6.0 より前のバージョンの worklight を使用している場合は、applicationDescriptor ファイルを調べて、デバイスが接続するサーバーとして「localhost」がハードコーディングされていないことを確認する必要があります。エミュレーターはワークライト サーバーと同じマシン上で実行されるため、localhost に問題なく接続できますが、デバイスには実際の IP アドレスが必要です。

また、デバイスのインターネット接続を再確認してください。

于 2013-08-03T09:07:37.310 に答える