locked
web reference test vs prod addresses RRS feed

  • Question

  • User390217 posted

    Hello! I'm writting an application for android and iOS that has several web service references.

    Currently we are testing changes to the webservices and need to easily switch the references in the app between the test service and the prod service. Idealy I would like to be able to put the address in a config file somewhere so I can change it easily. I'm just not sure how to set this up.

    Does anyone know how I might go about doing this? or any other suggestion to achieve something similar?

    thanks.

    Wednesday, November 6, 2019 6:06 PM

All replies

  • User89714 posted

    @shaboboo said: Hello! I'm writting an application for android and iOS that has several web service references.

    Currently we are testing changes to the webservices and need to easily switch the references in the app between the test service and the prod service. Idealy I would like to be able to put the address in a config file somewhere so I can change it easily. I'm just not sure how to set this up.

    Does anyone know how I might go about doing this? or any other suggestion to achieve something similar?

    thanks.

    Depending on how your builds are done, you could either add a new build configuration in Visual Studio's Configuration Manager with the different build configurations, or you could have your build system specify different compilation symbols for test and prod. Using different build configurations, you could either have the different configurations define different compilations symbols, or you could have them build different projects. Whichever of these options you go for, these give you mechanisms for accessing different code/data for test and prod.

    Thursday, November 7, 2019 10:02 AM
  • User390217 posted

    Thanks @JohnHardman ! You've led me in the right direction. I've set up a new build configuration, and used #if directives to set the webservice's URL property right after creating an instance of it in the code. Works like a charm!

    Thursday, November 7, 2019 5:20 PM
  • User89714 posted

    @shaboboo said: Thanks @JohnHardman ! You've led me in the right direction. I've set up a new build configuration, and used #if directives to set the webservice's URL property right after creating an instance of it in the code. Works like a charm!

    Great - glad it works. Don't forget to Like and/or mark as Accepted Answer the post above :-)

    Thursday, November 7, 2019 9:49 PM