looking for right design , two different webservices via compilation flag
I have two web services , with little bit differen开发者_如何学Got API for example :
void LOG(string , string ,out int)
int LOG(string ,string)
one of them is for production , and one is for testing .
What is the best practice in that case , how to write it in the code more nice looking ...
and not make ugly #IF #ELSE
statements in my main code.
The fist one is the production one , the second one is the test version.
And the functionality is the same in both versions.
the difference between them that I had a WSDL file from the original web service , i have used wsdl.exe yourFile.wsdl /l:CS /serverInterface
and got my test service , but when I added it as reference to my application I have got a different proxy , and function signatures been little bit different.no idea why.
but when I added it as reference to my application I have got a different proxy , and function signatures been little bit different.no idea why
I suppose it was made to avoid two methods with the same signature in web-service client's class. If I get you right, you have 2 instances of webservice with one interface. then you don't need to add two references to your project. Just specify location of web-service as a param on instantiation instead of using parameterless constructor.
UPDATE Technically (since you tagged it with 'design patterns') you could use Strategy pattern for calls together with dependency injection. But if these instances of w/s are completely equal, I suggest you to find what's wrong with these WSDL-s or generated client code. The problem is with generation of stubs, not with elegance in code.
精彩评论