Maintaining up to date Web Reference proxy classes across projects
posted on Friday, January 05, 2007 4:02 PM
by
kfinley
The other day I ran into a situation that I'm sure is pretty common these days.
How do you keep .NET XML proxy classes up to date for web references across projects in a team development environment?
My situation was even worse because the project which currently contains the web reference is actually used in a Visual Studio 2005 solution. Which means I can't even use the Update Web Reference option from Visual Studio if the service changes (I should have a post out soon explaining this setup).
So after giving this some thought I realized we could just generate the proxies outside of Visual Studio using the wsdl.exe utility whenever the service contract changes. (This is basically what I'm doing now but I'm using VS 2k3 to do the generation / updating). So since we can do this from a command line we have a few options.
- Include a call to Wsdl.exe in the build process
- Integrate the creation into the check in process
Obviously I like option two better but since the client I'm at currently doesn't have a full fledged Continuous Integration setup in place option one is our only choice.
So, how do we do this? It's really pretty easy. Since we are using NAnt for the build process we can just hook in some calls to generate the proxies inside the build script before the assembly is compiled. Conveniently enough this scenario has already been dealt with by the folks working on NAntContrib included the <wsdl> task. This was included to handle this exact scenario.
Here's an example of using the <wsdl> task:
<wsdl path=".....\myservice.wsdl" language="CS" namespace="MyCompany.MyService" outfile="MyService.cs" urlkey="WebServiceLocation">
Path can be a URL or a file path.
I've been pulled in another direction this week so I'm not working with that team anymore but I'm going to recommend they use this approach. If they run it it I'll grab a more complete example and post it.
If you're not familiar with the Wsdl.exe utility here are a few links from Microsoft.
Creating an XML Web Service Proxy
Web Services Description Language Tool (Wsdl.exe)