于webservice的异步调用简单实例
无论在任何情况下,被调用方的代码无论是被异步调用还是同步调用的情况下,被调用方的代码都是一样的,
下面,我们就以异步调用一个webservice为例作说明。
这是一个webservice
<WebMethod(Description:="试验")>_
PublicFunctiondelCurTable(ByValtbNameAsString)AsBoolean
Try
ReturnTrue
CatchexAsException
ReturnFalse
EndTry
EndFunction
关于这个webservice的同步调用方法,我就不做说明了
异步调用:
PrivateaAsvbwebservice.DataManage'定义一个webservice变量
DimarAsIAsyncResult
publicsubCallback1(byvalarasIAsyncResult)
''这里可以不写任何代码
'这里的代码在调用方运行结束后,开始运行
endsub
#region"异步调用"
privatesubbtnStart_Click()
dimcbasasyncallback=newasyncallback(address(me.callback1))
ar=a.begindelcurtable("zdf",cb,a)
endsub
privatesubbtnEnd_Click()
ifarisnothingthen
exitsub
endif
ifar.IsCompletedThen
dimmasboolean=a.enddelcurtable(ar)
messagebox.show(m.tostring)
endif
endsub
#endregion
注意:“返回异步调用的结果一次只能调用一次,如果想再执行一遍,就必须重新执行一遍begin的方法”
以上是vb.net的用法,下面是c#的用法
CWebService.DataManagea;
System.IAsyncResultar;
privatevoidForm1_Load(objectsender,System.EventArgse)
{
a=newCWebService.DataManage();
}
publicvoidCallBack1(System.IAsyncResultar)
{
}
privatevoidbtnStart_Click(objectsender,System.EventArgse)
{
System.AsyncCallbackcb=newAsyncCallback(this.CallBack1);
ar=a.BegindelCurTable("zhang",cb,a);
}
privatevoidbtnEnd_Click(objectsender,System.EventArgse)
{
if(ar==null)
{
MessageBox.Show("null");
return;
}
if(ar.IsCompleted)
{
boolm=a.EnddelCurTable(ar);
MessageBox.Show(m.ToString());
}
else
{
MessageBox.Show("为完成");
}
}
分享到:
相关推荐
网上有,但是只是介绍,没有现成的代码,现在我做了一个最简单的web服务,在客户端运用AJAX技术进行了调用,测试成功!
异步调用的小例子,方便学习使用。异步调用的小例子,方便学习使用。异步调用的小例子,方便学习使用。异步调用的小例子,方便学习使用。
浅析异步调用,PPT讲座。介绍了ajax webservice,remote的区别特点等。
异步调用 c.返回数据的处理 soap调用返回的数据经常放在:<webservice方法名Result>XXX</webservice方法名Result>中,在webservice调用中已经直接提取出来了,提取出来的内容还是一个xml,这段内容的处理,单独写在...
异步调用Web Service程序 小例子,C++.net源代码编写
NULL 博文链接:https://hyan.iteye.com/blog/2128321
使用axis2-eclipse-codegen-wizard-1.4生成代理方法调用SAP PI发布的Webservice,因为codegen-wizard不能识别Policy节点,所以需要手工将Policy节点删掉,此实例为异步场景 文档 + 代码 + Jar
异步调用webservice的一个例子
Jquery Ajax学习实例6 向WebService发出请求,返回DataSet(XML) 异步调用实现代码,需要的朋友可以参考下。
WebService传XML 简单实例 传送 [WebMethod] public XmlDataDocument GetSiteAData(string AssignName) { XmlDataDocument xd = new XmlDataDocument(); DataSet ds = BusinessWork.BusinessWorkDataSet...
Axis的简单准备 Axis的入门实例 Axis复杂对象类型的WebService Axis的辅助工具发布、调用WebService ...Axis异步调用WebService Axis 的Module模块 Axis使用SoapMonitar监视WebService的请求和响应信息
通过点击按钮来请求WebService.asmx的 GetList()方法,获取泛型集合。
Axis的简单准备 Axis的入门实例 Axis复杂对象类型的WebService Axis的辅助工具发布、调用WebService ...Axis异步调用WebService Axis的Module模块 Axis使用SoapMonitar监视WebService的请求和响应信息
Jquery Ajax学习实例4-向WebService发出请求,返回实体对象的异步调用
Axis 的简单准备 Axis 的入门实例 Axis 复杂对象类型的WebService Axis 的辅助工具发布、调用WebService ...Axis 异步调用WebService Axis 的Module 模块 Axis 使用SoapMonitar 监视WebService 的请求和响应信息
Axis的简单准备 Axis的入门实例 Axis复杂对象类型的WebService Axis的辅助工具发布、调用WebService ... Axis异步调用WebService Axis 的Module模块 Axis使用SoapMonitor监视WebService的请求和响应信息
在原作者(柳峰)的基础上进行了异步处理.原博客地址:http://blog.csdn.net/lyq8479/article/details/6428288