I'm developing an application that should connect to a number of Web services depending on the user's location.
For example :
If the user is in the city " A " he will connect to the Web service:
192.168.1.1:8010
if he goes to the city " B ",192.168.1.1:8020
, in the city " C "192.168.1.1:8030
, and so on.The address is always the same, what changes is the port.
Simple thing, right ?! Yeah, but I can not make it run at any time!
When I change the
URL
parameter of the Web service at runtime the server only returnsnull
, returning to the original value the communication resets. The same thing if the change is made before the compilation, that is, compile for the city " A ", works in the city " A ", B ", works in the city" B ".
The application was originally developed for Windows CE using VS2008 and CF3.5, but even in VS2013 with .Net Framework 4.0 the "problem" is repeated.
Has anyone ever been through this?
I created a new application just to test the exchange of the server, it follows the code:
WebReference.WSR testeWS = new WebReference.WSR();
private void btn_Troca_URL_Click(object sender, EventArgs e)
{
if (URL_01)
{
testeWS.Url = "http://192.168.1.1:8010/WSR.apw";
URL_01 = false;
}
else
{
testeWS.Url = "http://192.168.1.1:8020/WSR.apw";
URL_01 = true;
}
}
In this case the original URL (compiled) is "http://192.168.1.1:8010/WSR.apw"
and for this URL everything works normally, when I click the button and change to the URL "http://192.168.1.1:8020/WSR.apw"
, I only have null as a response. By clicking back and returning to the original URL, everything works again.
If the code is compiled for the URL "http://192.168.1.1:8020/WSR.apw"
the "problem" is reversed.
Remembering that the "URL Behavior" property is set to Dynamic.