18

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?

HBFan
  • 285
  • 2
  • 6
  • 2
    The web service and clients are written and used in house. I don't want to have to remember to manually update the web reference on every client project anytime time wsdl changes. – HBFan Oct 01 '08 at 21:00

4 Answers4

17

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 &quot;$(OutDir)&quot; /n &quot;$(WebServiceNamespace)&quot; &quot$(PathToWebServiceURL)&quot;"/>
  </Target>
Steve Goykovich
  • 757
  • 1
  • 9
  • 17
Vivek
  • 16,360
  • 5
  • 30
  • 37
1

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

azamsharp
  • 19,710
  • 36
  • 144
  • 222
1

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
  • 23,436
  • 10
  • 47
  • 51
0

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
  • 74,861
  • 18
  • 132
  • 169