0

我是学习Android应用程序开发的初学者。这是我的问题

我正在使用与 Android SDK 一起提供的 Eclipse 来开发应用程序。要启用 Web 应用程序,我使用 phonegap 构建教程添加了 cordova API。现在,如果我只使用普通的 HTML 控件或文本,我就可以看到 html 文件。但我有一个代码,它从另一个 WebSphere 服务器调用 web 服务并显示数据。当我在 IIS 服务器中运行代码时(使用 DreanWeaver IDE),它运行良好。但是当我尝试在模拟器中将其作为应用程序运行时(来自 Android SDK),我没有看到来自 web 服务的任何输出。我什至看不到从 android 应用程序到我的 webspehere 服务器的调用(当我在 Dreamweaver 中将此代码作为网页运行时可以看到)。这是我的 index.html 代码。如果有人对此感到疑惑,我已将 ws.js 和 prototype.js 包含在 assets/www/scripts/ 中。有人可以帮我解决这个问题。

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
    <meta charset="utf-8">

    <script type="text/javascript" src="scripts/prototype.js"></script>
    <script type="text/javascript" src="scripts/ws.js"></script>
    <script type="text/javascript">

    function onBodyLoad(name, container)
    {
        console.log("Here1"); 
        var call = new WS.Call('http://localhost:9080/ILM/services/ILMReports'); 
        var nsuri = '';
        var qn_op = new WS.QName('getInboundSearchByItemReport',nsuri);
        var qn_op_resp = new WS.QName('getInboundSearchByItemReportResponse',nsuri);  

        call.invoke_rpc(
        qn_op,
        new Array(
        {name:'name',value:name}
        ),null,
        function(call,envelope) {
            var ret = 
            envelope.get_body().get_all_children()[0].
              get_all_children()[0].get_value();
            container.innerHTML = ret;
            }
        );

        /*window.location = "TestingAJAXWS.html";*/
    }

    function onDeviceReady()
    {
        // do your thing!
        navigator.notification.alert("PhoneGap is working")
    }

    </script>
</head>
<body onload="onBodyLoad('aaa',$('result'))">
<h1>Hey, it's PhoneGap!</h1>
</body>

4

1 回答 1

0

我可以看到的问题是您用于访问 Web 服务的本地主机地址。

不知何故,android模拟器不允许本地主机地址,因为模拟器不知道。(如果你知道原因请写)

这是一种旧思路。但我希望它会帮助别人。/T

于 2013-10-13T11:01:06.450 回答