Begin and End Async method web service proxy not generated

When you add Web Reference in web site project you would have seen the Begin and End methods are getting added for corresponding web service method, which are used for Async call. The Async method and completed event are also getting added along with these methods.  For example when you add web reference for your web service which has one method “AddNum”, the following methods and event will be generated in proxy.

·         AddNum,

·         BeginAddNum,

·         EndAddNum,

·         AddNumAsync,

·         AddNumCompleted,

But when you add Web Reference in class library project or web application project you would have noticed the Begin and End Async methods are no longer exist.  There could be scenarios when you want to use Begin and End method as the other set of method <methodName>Async and its completed event is an event based solution and if you want to cosume event based Async pattern, you have to enable Async at page level (in aspx page directive Async=True).

There is workaround to generate these methods in web service proxy.
You can set project property WebReference_EnableLegacyEventingModel to “true” to enable this.

To implement this, unload your project and edit the project file. Add below line inside “PropertyGroup” element.

<WebReference_EnableLegacyEventingModel>true</WebReference_EnableLegacyEventingModel>

Save your project file and reload your project into solution. Now when you add web reference you can see the Begin and End method in generated proxy.