If you have added a Web Reference for a Web Service recently you may have noticed that the wsdl tool no longer creates Begin
and End methods for you, instead it implements what is known as the Event based
Async Pattern. Which is fine if you are building a Windows or Console application, but if you are trying to call a web service asynchronously using the AddOnPreRenderAsync or RegisterAsyncTask methods in ASP.NET you really need a Begin method that returns an IAsyncResult Interface. There are several ways you can work around this.
You could, assuming you still have it, create a project in Visual Studio 2003, add the web reference there and copy it to your 2005 project, or you can run the wsdl tool manually and use the /parameters option to
specify a configuration file with the "oldAsync" flag. For example, for a reference to http://my.server.com/service, which creates a proxy class with both begin/end (a.k.a. "old style") and
event-based (a.k.a. "new style") methods, you'd use the command
wsdl.exe /parameters:MyParameters.xml http://my.server.com/service
Where MyParameters.xml is as below:
<codeGenerationOptions>properties oldAsync newAsync</codeGenerationOptions>
However, my preferred method is to set a project level property WebReference_EnableLegacyEventingModel to true.
do that, you need unload the project from Visual Studio, and edit the project file
directly in a text editor. (I recommend creating a backup first)
In the first section of PropertyGroup, you will see many properties like:
Don't change any of those, but do add a new property into that section:
Save the file, and reload the project into Visual Studio.
After that, you have to regenate all proxy code (by updating the reference, or running the custom tool on the .map file)
This is my preferred method because unlike the others I described, this one lets you refresh or update the web reference as normal, which if your project is shared with other developers is a big plus!