记得以前有人问过,不错的文章。
Calling WebServices using Javascript

If you are using Microsoft IE 5 or later, you can use the behavior/HTML-Component "WebService" to access a Web service. The "WebService" behavior communicates with Web services over HTTP using Simple Object Access Protocol (SOAP).

To use the "WebService" behavior, you must attach it to an element using the STYLE attribute, as follows:

<DIV ID="GiveItAName"
STYLE="behavior:url(webservice.htc)"></DIV>

A complete example taken from the Microsoft Web site is as follows:

<html>
<head>
<script language="JavaScript">
var iCallID;

function init()
{
service.useService
("
http://myserver.com/services/myservice.asmx?WSDL",
                   "servicename");
}

function onmyresult()
{
   if ((event.result.error)&&(iCallID==event.result.id))
   {
      var xfaultcode = event.result.errorDetail.code;
      var xfaultstring = event.result.errorDetail.string;
      var xfaultsoap = event.result.errorDetail.raw;

      // Add code to output error information here
      alert("Error ");
   }
   else
   {
      service.innerHTML= "The method returned the result: "
                         + event.result.value;
   }
}
</script>
</HEAD>
<body onload="init();">
<BR>
Enter a Value <input type='text' id='param1'>
<BR>
<button onclick='iCallID = service.servicename.callService
("ProcedureName", param1.value);'>Call A Web Method</button>
<div >http://weblogs.asp.net/Varad/archive/2004/06/14/155671.aspx

相关文章:

  • 2022-12-23
  • 2021-08-18
  • 2021-12-23
  • 2021-11-04
  • 2021-10-21
  • 2021-07-29
  • 2022-01-15
猜你喜欢
  • 2021-10-24
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-01-16
相关资源
相似解决方案