需要一个简单的ASP.NET异步回调到Web服务

时间:2011-02-12 02:03:08

标签: asp.net vb.net web-services asynchronous

我一直试图把这个问题弄得太久,我无法理解它。我看到的每个例子似乎都比我需要的要复杂得多。

我的项目中有一个Web服务(.asmx)。我想通过网页上的按钮简单地调用它。

  1. 点击
  2. 异步运行服务
  3. 将控制权返回给网页(网络 服务在后台运行)
  4. 有人可以在vb中向我展示一个简单的例子,或者甚至他们认为可以帮助我更好地理解我需要做什么的事情吗?

1 个答案:

答案 0 :(得分:1)

使用jQuery库(不是唯一的选项,但是一个非常好的选项)大大简化了这个问题。以下是按钮的onclick事件中放置内容的示例:

$.post('MyWebService.asmx', '<?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
      <Contact xmlns="http://mywebsite.com/">
        <firstName>string</firstName>
        <lastName>string</lastName>
      </Contact>
    </soap:Body>
  </soap:Envelope>');

此处有更多信息:http://api.jquery.com/jQuery.post/

相关问题