26. July 2007 10:00
This is the next post in my mini-series on some highlights of svcutil.
One of the most common questions I am asked that leads into a conversation about svcutil is "How do I generate a proxy with asynchronous methods?" If you have worked very much with ASP.NET web services (ASMX), you are probably used to seeing methods in your proxy that are prefixed with Begin and End. For example, let's say that your web service has a method named Foo. A proxy generated by the wsdl utility (or even directly by Visual Studio) will contain a Foo method as well as BeginFoo and EndFoo methods. If you execute the Foo method, the web service operation is invoked synchronously. However, you can leverage the BeginFoo and EndFoo methods to asynchronously invoke the corresponding web service operation.
If you are accustomed to using these asynchronous methods, you will quickly find them to be missing from a WCF proxy that gets generated by Visual Studio. For whatever reason, the asynchronous methods are no longer generated by default. There is a specific switch in svcutil that is required in order to output the asynchronous methods. Unfortunately, the switch isn't used when generating a proxy via Visual Studio. Fortunately, it is quite simple to do via svcutil.
All that is required is adding an additional switch: /async or /a for short.
Here is an example command that will generate asynchronous methods from a service that is already running:
svcutil /t:code http://localhost/myService /out:Proxy.cs /config:Proxy.config /async
Here is a command that will generate asynchronous methods from local wsdl and xsd files:
svcutil /t:code *.wsdl *.xsd /out:Proxy.cs /config:Proxy.config /async
f39d8ca9-df2e-4dfe-b46b-9fc83e315ac5|0|.0
By: Jeff Barnes
Category:
Tags: