在解决方案的“引用”上右键选择“添加服务引用”,输入webservice地址之后勾选“允许生成异步操作”
然后修改web.config(app.config),删除其中一个绑定,或者将其中一个改名
然后编写代码:
static void Main(string[] args)
{
ws1.LiftInfoSoapClient ws = new ws1.LiftInfoSoapClient();
ws.ValidateDriverCompleted += new EventHandler<ws1.ValidateDriverCompletedEventArgs>(
(object s, ws1.ValidateDriverCompletedEventArgs e) =>
{
Console.WriteLine("2 " + e.Result);
}
);
Console.WriteLine("1");
ws.ValidateDriverAsync("123");
Console.ReadKey();
}