首页  ·  知识 ·  前端
Javascript调用Webservice的汇集
佚名  www.chinaitlab.com  综合  编辑:dezai  图片来源:网络
通过xmlhttp+webservice(原始方法) 原文地址:http://netboy.cnblogs.com/archive/2006/02/18/333260.html using System;

通过xmlhttp+webservice(原始方法)

原文地址:http://netboy.cnblogs.com/archive/2006/02/18/333260.html

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[webservice(namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {

//uncomment the following line if using designed components
//InitializeComponent();
}

[webmethod]
public string SayHelloTo(string Name) {
return "Hello "+Name;
}

}
还是俗了点。:)

2. js调用webservice+xmlhttp的实现部分。


<BR>Call webservice with javascript and xmlhttp.<BR>




对于使用post方法需要发送的那堆东东可以在webservice的测试页面中找到,自己拼凑加上对应的参数就可以。

通过style.behavior来实现的方法(比较简单)

原文地址:http://www.zahui.com/html/4/37953.htm


页面显示部分:

ok,这给我们在静态页调用动态的内容提供了一种途径;
这里如果给getfemale()函数加上定时调用的话,就是一种无刷新更新页面的机制了。
缺点是webservice会有一定的延迟,即使是本地的webservice也会比静态页面慢很多,初次打开页面会感觉很不协调。

 

第二种方法使用了style.代码就简洁多了他使用了css.定义了div的行为.比起第一种方法,就易读多了:)

style="behavior:url(webservice.htc)"

前提条件是:

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).

附注:另一个总结帖子在:http://goody9807.cnblogs.com/archive/2005/08/17/216725.html

 

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:

 

style="behavior:url(webservice.htc)">

本文作者:佚名 来源:www.chinaitlab.com
CIO之家 www.ciozj.com 微信公众号:imciow
   
免责声明:本站转载此文章旨在分享信息,不代表对其内容的完全认同。文章来源已尽可能注明,若涉及版权问题,请及时与我们联系,我们将积极配合处理。同时,我们无法对文章内容的真实性、准确性及完整性进行完全保证,对于因文章内容而产生的任何后果,本账号不承担法律责任。转载仅出于传播目的,读者应自行对内容进行核实与判断。请谨慎参考文章信息,一切责任由读者自行承担。
延伸阅读