Ibm mobilefirst 在ibm Worklight中获取json响应,实际设备中不显示值

Ibm mobilefirst 在ibm Worklight中获取json响应,实际设备中不显示值,ibm-mobilefirst,worklight-adapters,Ibm Mobilefirst,Worklight Adapters,我是worklight新手,在我的应用程序中,我通过work light适配器获得JSON响应。在emulator中,只有在调用work light过程后,响应才会正确显示。 但当我在实际设备中运行它时,响应并没有显示出来。有谁知道能帮我解决这个问题吗 我的适配器XML代码: <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed Materials - Property of IBM 5725-G92 (C) Copyrigh

我是worklight新手,在我的应用程序中,我通过work light适配器获得JSON响应。在emulator中,只有在调用work light过程后,响应才会正确显示。 但当我在实际设备中运行它时,响应并没有显示出来。有谁知道能帮我解决这个问题吗

我的适配器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>
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"
  }
],
我的儿子的反应

 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"
  }
],

您正在使用哪个版本的worklight?如果您使用的是6.0之前版本的worklight,则应检查applicationDescriptor文件,以确保没有将“localhost”硬编码为设备连接到的服务器。您的模拟器可以很好地连接到localhost,因为它与worklight server在同一台计算机上运行,但您的设备需要实际的IP地址


还要确保再次检查设备上的internet连接。

am使用work light 6.0。我的设备有internet连接。如何设置IP地址。当试图从设备调用适配器时,会收到什么错误消息?是否可能存在阻止设备与worklight server通信的情况?像防火墙一样?如何从设备调用适配器。我没有从设备调用适配器。我只是在设备中运行apk文件。有关从设备调用适配器的信息,请参阅以下文档: