views:

948

answers:

5

I have a .net project that has a web reference to a service. I would like to update that web reference as part of every build. Is that possible?

+1  A: 

Also, when you are deploying your webservices on production make sure that they are set as Dynamic and not static.

azamsharp
A: 

You can use svcutil (http://msdn.microsoft.com/en-us/library/aa347733.aspx) tool to generate the web reference for you. The tool will generate the proper client proxy classes and the proper config (and it can even merge it in your application config). Keep in mind that the tool requires .Net 3.0 and will generate WCF-style client proxies and configuration.

Franci Penov
+2  A: 

You can use MSBuild script with a task that calls wsdl.exe

  <Target Name="UpdateWebReference">
    <Message Text="Updating Web Reference..."/>
    <Exec Command="wsdl.exe /o &quote;$(OutDir)&quote; /n &quote;$(WebServiceNamespace)&quote; &quote$(PathToWebServiceURL)&quote;"/>
  </Target>
Vivek
A: 

You can do it using the methods provided by the other answerers, but you have to know that doing this could cause your build to fail. If the WSDL was changed, the generated code is also going to change and your code may no longer compile.

Dan Goldstein
A: 

Vivek's answer was correct. I did not specify that I needed unmanaged c++ code for the proxy. For that I had to use sproxy.exe instead of wsdl.exe.

HBFan