I have an application written in C# using .Net CF 2.0 which consumes a web service which sits on one of my servers. My device is running WM5 and the dev env is Visual Studio 2005.
In the code, I create the web service, check there's a valid internet connection like this:
...
req = ((HttpWebRequest)(WebRequest.Create("http://www.microsoft.com")));
res = ((HttpWebResponse)(req.GetResponse()));
if(res.StatusCode == HttpStatusCode.OK)
return true;
...
and then invoke a method on the webservice.
This all works fine with the device cradled until I change my network settings to go via a proxy server.
The PPC seems to pick up these proxy settings after a reset and I can see the web service via IE on the device. However, when I run the code it fails as soon as I try to invoke a method on the web service. The calls to the WebRequest used to check the internet connection still succeeds, but the webservice calls fail.
The exception's HResult is -2146233079 and the _message is "WebException", there is no innerexception.
I've tried setting the following just before I create the webservice:
System.Net.GlobalProxySelection.Select = new System.Net.WebProxy("http://192.168.x.x:6588");
and I also set the following when I create the webservice:
cws.Proxy = new System.Net.WebProxy("http://192.168.x.x:6588");
both of which are using the correct IP and port number.
but this has no effect.
I'm assuming that if the internet connection is fine in the app then I shouldn't need to make these calls anyway. I also assume that I'd only need to set the System.Net.GlobalProxySelection.Select and all subsequence web requests would then use these setting so there'd be no need to specify the proxy when I create the web service.
Does anyone know what the problem is