I have project setup dilemma. In fact I know it is not a good design but let me share what I have right now.
I was wondering if there is any easy way to switch between QA and production webservice without recompiling my code separately for both environments.
Currently in my project, I added two web references one for QA and one for Production. Both contain seperate URLs (right lick references>add reference>etc etc). it is an asmx file.
In code,
using System; using Reference1.qa;
//using Reference2.prod;
UserUpdateSVC ws = new UserUpdateSVC();
As you can see, that I instantiate an object of a webservice class after I include the the reference at the top of the code.
Problem is that if I want to deploy to PROD environment, then I have to uncomment the production reference and comment out the qa reference because it points to a different URL and I have to recompile the application again because we are using Dlls to deploy
So basically for different environment, I have to switch the code and recompile it and generate separate dll. I know this is not right way of doing this but I'm using the reference to get method definition which is available for me to use.
Please advise with any code sample to give me an idea how I can avoid this redundant process and what alternative way I can instead apply.
Member
1 Points
18 Posts
How to switch web service environments in code?
May 12, 2020 09:01 PM|shehz|LINK
I have project setup dilemma. In fact I know it is not a good design but let me share what I have right now.
I was wondering if there is any easy way to switch between QA and production webservice without recompiling my code separately for both environments.
Currently in my project, I added two web references one for QA and one for Production. Both contain seperate URLs (right lick references>add reference>etc etc). it is an asmx file.
In code,
As you can see, that I instantiate an object of a webservice class after I include the the reference at the top of the code.
Problem is that if I want to deploy to PROD environment, then I have to uncomment the production reference and comment out the qa reference because it points to a different URL and I have to recompile the application again because we are using Dlls to deploy
So basically for different environment, I have to switch the code and recompile it and generate separate dll. I know this is not right way of doing this but I'm using the reference to get method definition which is available for me to use.
Please advise with any code sample to give me an idea how I can avoid this redundant process and what alternative way I can instead apply.
Thank You!