PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework WebService access issue on GPRS/3G

Reply

WebService access issue on GPRS/3G

 
Thread Tools Rate Thread
Old 22-04-2008, 10:00 PM   #1
Fred
Guest
 
Posts: n/a
Default WebService access issue on GPRS/3G


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
  Reply With Quote
Old 23-04-2008, 09:32 AM   #2
davebythesea
Guest
 
Posts: n/a
Default RE: WebService access issue on GPRS/3G

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
>

  Reply With Quote
Old 23-04-2008, 02:04 PM   #3
Fred
Guest
 
Posts: n/a
Default Re: WebService access issue on GPRS/3G

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();
}
  Reply With Quote
Old 23-04-2008, 04:41 PM   #4
davebythesea
Guest
 
Posts: n/a
Default Re: WebService access issue on GPRS/3G

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();
> }
>

  Reply With Quote
Old 23-04-2008, 05:02 PM   #5
davebythesea
Guest
 
Posts: n/a
Default Re: WebService access issue on GPRS/3G

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();
> }
>

  Reply With Quote
Old 24-04-2008, 02:43 PM   #6
Fred
Guest
 
Posts: n/a
Default Re: WebService access issue on GPRS/3G

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
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off