1

I have inherited a .NET 4 VS2010 solution consisting of a WinForms app and a web service. I don't have access to a server that's running a copy of the web service but I have to run, debug, upgrade and test the project that accesses the web service as well as the web service code.

Later, I also want to quickly switch between a deployed web service and the code in my local project

What's the best strategy for changing the projects so I can make changes to both projects, test locally, deploy the web service then test against that? If I find issues, I want to switch back to "local" mode to debug.

Thanks team!

2 Answers 2

6

The easiest is to host the service locally in visual studio and change the service url to switch between the production service and the local one. You can automatically switch between the services by checking for Debug and Release modes using #if and #else directives.

You can also use the interface to provide a stub of the service. This will also make unit testing easier.

2
  • Thanks! This is suggesting the isolation of the webservice consumer winforms program and the web service itself. Currently the winforms program has a web reference to the web service project, which resolves to a localhost address in app.config. They are both in the same solution. But the targets in the .wsdl file and auto generated reference.vb remain the IP address of the remote server. It seems with web services, the target URL is scattered amongst a number of files. Apr 18, 2011 at 17:57
  • Also, since the web reference is automagically placed into ApplicationSettings in the WinForms app.config, I can't use #IF there. Separating the projects to be in different solutions may indeed be the best stategy. Apr 18, 2011 at 17:59
1
  • Host your web service in IIS or using a local development web server (cassini)
  • Use app.config to store the address of the web server
  • Get the code to use the build the endpoint of the web service based on the app.config
  • Change web server address in the web.config to switch between servers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.