0

我需要调用一个用 Java 构建的 Web 服务,以便通过 Java 脚本从 HTML 页面调用。

我尝试了以下 URL 提供的代码示例:http: //www.codeproject.com/Articles/14610/Calling-Web-Services-from-HTML-Pages-using-JavaScr#

  <html>
  <head>
   <title>Hello World</title>
    <script language="JavaScript">
     var iCallID;
     function InitializeService(){
      service.useService(http://localhost:1394/MyWebService.asmx?wsdl, 
    "HelloWorldService");
      service.HelloWorldService.callService("HelloWorld");
     }
     function ShowResult(){
      alert(event.result.value);//Output: Undefined
     }
    </script>
   </head>
  <body onload="InitializeService()" id="service" 
    style="behavior:url(webservice.htc)" onresult="ShowResult()"> </body>
 </html>

Web 服务正在运行,并已通过 Weblogic 内置测试客户端进行了测试。

请建议一些用于使用字符串参数调用 web 服务的 JS 代码

4

1 回答 1

0

Ajax. Be careful though, it only allows requests on the same domain (browsers limitation). If you want cross-domain support, either use JSONP (if the webservice allows it), or use a server as a proxy, so that:

Javascript -> Server on same domain -> WebService
于 2012-04-19T06:03:00.910 回答