Legacy ASMX webservice - How to use automagically

2019-07-25 01:14发布

In a asmx webservice i use with c# class library project after adding the web reference to the project which exposes the WebMethods inside the service there are multiple method names for example,

In my service i have a webmethod named GetCategories but the intellisense also shows GetCategoriesAsync

Is this a asynchronous call to the same webmethod? If so how can i invoke this asynchronous method any examples ?

1条回答
Deceive 欺骗
2楼-- · 2019-07-25 01:37

You can call the method the same as you call the regular method, you should also sign up a function to the method completion event so that upon a response you could continue the proccess.

this is an example I found

protected void Button1_Click
(object sender, EventArgs e)
{
     BookSupplier1.WebService1 supplier1 = new BookSupplier1.WebService1();

     supplier1.GetCostCompleted += new BookSupplier1.GetCostCompletedEventHandler(supplier1_GetCostCompleted);

     supplier1.GetCostAsync(TextBox1.Text, BulletedList1);

}


void supplier1_GetCostCompleted(object sender, BookSupplier1.GetCostCompletedEventArgs e)
{
     if (e.Error != null)
     {
         throw e.Error;
     }
     BulletedList list = (BulletedList)e.UserState;
     list.Items.Add("Quote from BookSupplier1 : " + e.Result.ToString("C"));
}

Example Link

查看更多
登录 后发表回答