2012-01-02 59 views
1

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

<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

你的HTML引用在同一台机器 http://localhost:2913

我不认为你有你的android手机上运行的Web服务上的服务。

与您的服务器

+0

的IP我试图与服务器IP地址替换“本地主机”代替localhost。但是,它没有奏效。 – user1082868 2012-01-02 08:40:19

+0

是从android手机可以访问的服务器吗?即你可以从你的手机html-broser获得你的服务的html页面吗? – k3b 2012-01-02 08:54:21

+0

我在模拟器上运行代码。当我尝试从Android模拟器上加载的HTML页面调用Web服务时,没有任何反应。 – user1082868 2012-01-02 09:29:02