从Android浏览器发出调用Web服务的问题

时间:2012-01-02 07:14:21

标签: android browser service web

我一直致力于从Android浏览器(Android 2.2)调用html5中的简单Web服务。它不适用于Android浏览器。但是,如果我在PC上运行它,它可以工作。单击按钮时没有任何反应。我已经上网几个星期了。但是,没有任何工作。下面是html页面的代码。请帮忙。

 <html>
  <head>
   <title>UseSwap</title>
    <script language="JavaScript">
     function InitializeService(){
      service.useService("http://localhost:2913/WebServicesUsingCSharp/WebService.asmx?wsdl",
    "GetAgeService");

     }
     var StrYear, StrMonth, StrDay;
     function GetAge(){
      StrYear = document.DemoForm.StringYear.value;
      StrMonth = document.DemoForm.StringMonth.value;
      StrDay = document.DemoForm.StringDay.value;
      service.GetAgeService.callService("GetAge", StrYear, StrMonth, StrDay);
     }
     function ShowResult(){
    alert(event.result.value);
      }
     </script>
    </head>
     <body onload="InitializeService()" id="service"
    style="behavior:url(webservice.htc)" onresult="ShowResult()">
       <form name="DemoForm">
       Year : <input type="text" name="StringYear"/>
       Month : <input type="text" name="StringMonth"/>
       Day : <input type="text" name="StringDay"/>
       <button onclick="GetAge()">Get Age</button>
      </form>
     </body>
 </html>

此致 Parshant。

1 个答案:

答案 0 :(得分:1)

你的html引用同一台机器上的服务     http://localhost:2913

我不认为您的Android手机上运行了web服务。

用服务器的IP替换localhost