PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
WebService access issue on GPRS/3G
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
WebService access issue on GPRS/3G
![]() |
WebService access issue on GPRS/3G |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi everyone,
I'm trying to build an application that retrieves data from a web service using its data connection (GPRS/3G). I'm testing this application on an HTC P3650 running windows mobile 6, with .NET CF SP2. As long as the device is connected through activesync, or with a WiFi connection, it works fine. However, when the device is connecting through its data connection, it throws a WebException. On the other hand, I can access the webservice through GPRS without a problem using IE. I know the operator restricts data access to avoid traffic other than http. The APN and proxy settings (which are used for this connection but not through wifi) are configured correctly, but I don't know if I should do anything else. Any idea would help, Thanks |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Hi Fred,
In your program, have you configured the Web Service to use Web Proxy settings? If so, I dont think you need to use the Proxy settings when using the Web Service straight over the internet using GPRS. Also, it might be worthwhile chucking some extra debug information in there to see exactly what Web Exception is being thrown. David Kline has a nice article on using the Web Exception class - http://blogs.msdn.com/davidklinems/.../10/228169.aspx Cheers, David "Fred" wrote: > Hi everyone, > > I'm trying to build an application that retrieves data from a web > service using its data connection (GPRS/3G). I'm testing this > application on an HTC P3650 running windows mobile 6, with .NET CF > SP2. > > As long as the device is connected through activesync, or with a WiFi > connection, it works fine. However, when the device is connecting > through its data connection, it throws a WebException. > On the other hand, I can access the webservice through GPRS without a > problem using IE. > > I know the operator restricts data access to avoid traffic other than > http. The APN and proxy settings (which are used for this connection > but not through wifi) are configured correctly, but I don't know if I > should do anything else. > > Any idea would help, > Thanks > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
thanks David,
I followed your advice on the webexception, and it returns "Forbidden" (both for the status code and the description) I had not configured the web service to use any web proxy settings. I've tried setting the server which are already configured in the connection settings of the phone for http traffic, but it returns the same error. I think it should automatically use these settings shouldn't it? It works fine when connected in wifi. When connected through activesync, it returns an SendFailure exception (no result). Below is the code I stripped of anything unrelated. Button1 calls the web service with or without proxy settings Button2 calls the url directly, and it works with any type of connection (except activesync -> sendfailure). private void button1_Click(object sender, EventArgs e) { Demographics.DemographixQuery dq = new DeviceApplication2.Demographics.DemographixQuery(); if (checkBox1.Checked) dq.Proxy = new WebProxy("195.115.25.129", 8080);// proxy for http access (already in device settings) try { label1.Text = dq.GetVersion(); } catch (WebException we) { // check the response HttpWebResponse response = we.Response as HttpWebResponse; if (null != response) { // get the reason for the exception HttpStatusCode status = response.StatusCode; String description = response.StatusDescription; // close the response response.Close(); label1.Text = dq.Proxy.ToString(); label2.Text = String.Format("- description:{0}\n- status{1}",description, status.ToString()); } // do any further exception processing here } private void button2_Click(object sender, EventArgs e) { String url = "http://ws.cdyne.com/DemographixWS/ DemographixQuery.asmx"; HttpWebRequest myReq = WebRequest.Create(url) as HttpWebRequest; WebResponse wr = myReq.GetResponse(); label1.Text = wr.ToString(); System.IO.Stream str = wr.GetResponseStream(); System.IO.StreamReader sr = new System.IO.StreamReader(str); label2.Text = sr.ReadToEnd(); } |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Hi Fred,
Does this make a difference - WebProxy proxy = new WebProxy("195.115.25.129:8080", true); proxy.Credentials = System.Net.CredentialCache.DefaultCredentials; dq.Proxy = proxy; David "Fred" wrote: > thanks David, > > I followed your advice on the webexception, and it returns > "Forbidden" (both for the status code and the description) > > I had not configured the web service to use any web proxy settings. > I've tried setting the server which are already configured in the > connection settings of the phone for http traffic, but it returns the > same error. I think it should automatically use these settings > shouldn't it? It works fine when connected in wifi. When connected > through activesync, it returns an SendFailure exception (no result). > Below is the code I stripped of anything unrelated. Button1 calls the > web service with or without proxy settings > Button2 calls the url directly, and it works with any type of > connection (except activesync -> sendfailure). > > private void button1_Click(object sender, EventArgs e) > { > Demographics.DemographixQuery dq = new > DeviceApplication2.Demographics.DemographixQuery(); > if (checkBox1.Checked) > dq.Proxy = new WebProxy("195.115.25.129", 8080);// > proxy for http access (already in device settings) > try > { > label1.Text = dq.GetVersion(); > } > catch (WebException we) > { > // check the response > HttpWebResponse response = we.Response as > HttpWebResponse; > > if (null != response) > { > // get the reason for the exception > HttpStatusCode status = response.StatusCode; > String description = response.StatusDescription; > // close the response > response.Close(); > label1.Text = dq.Proxy.ToString(); > label2.Text = String.Format("- description:{0}\n- > status{1}",description, status.ToString()); > } > > // do any further exception processing here > } > > > private void button2_Click(object sender, EventArgs e) > { > String url = "http://ws.cdyne.com/DemographixWS/ > DemographixQuery.asmx"; > HttpWebRequest myReq = WebRequest.Create(url) as > HttpWebRequest; > WebResponse wr = myReq.GetResponse(); > label1.Text = wr.ToString(); > System.IO.Stream str = wr.GetResponseStream(); > System.IO.StreamReader sr = new > System.IO.StreamReader(str); > label2.Text = sr.ReadToEnd(); > } > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Hi Fred,
I just tried that web service on a PPC2003 device here in the office. We use a proxy server here. This worked for me, it returned .6 as the Version. private void button1_Click(object sender, EventArgs e) { Service.DemographixQuery service = new Stub.Service.DemographixQuery(); WebProxy proxy = new WebProxy("http://192.168.1.202:8080", true); proxy.Credentials = new NetworkCredential("dave", "secret", "domain1"); service.Proxy = proxy; try { label1.Text = service.GetVersion(); } catch (Exception ex) { textBox1.Text = ex.Message; } } I reckon if you substitute your credentials in there and proxy server url it might work? David "Fred" wrote: > thanks David, > > I followed your advice on the webexception, and it returns > "Forbidden" (both for the status code and the description) > > I had not configured the web service to use any web proxy settings. > I've tried setting the server which are already configured in the > connection settings of the phone for http traffic, but it returns the > same error. I think it should automatically use these settings > shouldn't it? It works fine when connected in wifi. When connected > through activesync, it returns an SendFailure exception (no result). > Below is the code I stripped of anything unrelated. Button1 calls the > web service with or without proxy settings > Button2 calls the url directly, and it works with any type of > connection (except activesync -> sendfailure). > > private void button1_Click(object sender, EventArgs e) > { > Demographics.DemographixQuery dq = new > DeviceApplication2.Demographics.DemographixQuery(); > if (checkBox1.Checked) > dq.Proxy = new WebProxy("195.115.25.129", 8080);// > proxy for http access (already in device settings) > try > { > label1.Text = dq.GetVersion(); > } > catch (WebException we) > { > // check the response > HttpWebResponse response = we.Response as > HttpWebResponse; > > if (null != response) > { > // get the reason for the exception > HttpStatusCode status = response.StatusCode; > String description = response.StatusDescription; > // close the response > response.Close(); > label1.Text = dq.Proxy.ToString(); > label2.Text = String.Format("- description:{0}\n- > status{1}",description, status.ToString()); > } > > // do any further exception processing here > } > > > private void button2_Click(object sender, EventArgs e) > { > String url = "http://ws.cdyne.com/DemographixWS/ > DemographixQuery.asmx"; > HttpWebRequest myReq = WebRequest.Create(url) as > HttpWebRequest; > WebResponse wr = myReq.GetResponse(); > label1.Text = wr.ToString(); > System.IO.Stream str = wr.GetResponseStream(); > System.IO.StreamReader sr = new > System.IO.StreamReader(str); > label2.Text = sr.ReadToEnd(); > } > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Hi Dave,
No luck with this either. I think the problem comes from the fact that my wireless operator is filtering traffic. It offers two different APNs. One is unlimited in the plan, and allows http traffic only. For this one it requires going through this proxy server, which rejects the request. The other one is not included in the plan, and it works fine, I get .6 as well. What I can't figure out is what's the difference between this request and a normal webrequest (which goes through), and how can I modify the code to bypass the operator's restrictions. Thanks a lot for your help, Fred |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

