WebException

N

Neville Richardson

I have tested a simple HelloWorld web service which works fine when called
from PCs or Browsers but when I call this service from a Smartphone or
PocketPC more than once I get a WebException. (Servers used are Windows
2003)

Any one experienced this problem? What is the solution?

Thanks
 
T

Tom Krueger [MSFT]

Hi Neville,

Have you looked into what type of WebException is occuring? You can check
the WebException.Status to get an idea of what type of exception it is. You
can also get the response of the WebException to see what is coming back.
Here is some code (it may not be perfect).

} catch (System.Net.WebException webe) {
if (webe.Status == System.Net.WebExceptionStatus.ProtocolError) {

System.Net.WebResponse response = webe.Response;
if (response != null) {
System.IO.StreamReader sr = new
StreamReader(response.GetResponseStream());
string s = sr.ReadToEnd();
System.Console.WriteLine(s);
}
throw new Exception(String.Format("Error reading URL '{0}'.", url),
webe);
}
}

If you figure it out, it would be great if you would post what was happening
so we all can benefit. If you have more questions, post them as well.

Hope this helps,


Tom Krueger
Microsoft Corporation
Program Manager
http://weblogs.asp.net/tom_krueger

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
N

Neville Richardson

Hi,

Thanks for the input.

The exception is a ProtocolError on the m_Status property of the
exception. I tried your sample code and I do not receive anything back
into the string from the StreamReader.

Personally I am lost on this one. I do know that it does work on
different servers I've tried exactly the same web service on a different
web server and it works fine, both are 2003, but unfortunately I do not
have access to find out the differences of the servers. I have asked the
network administrators in charge of them and they have been unable to
help either.

The problem is a combination of using the compact framework to call web
services on servers setup in certain ways.

As this problem does not occur on PC or Browser devices then I
personally log it down to an undocumented bug in the .NET compact
framework V1.1
 
T

Tom Krueger [MSFT]

Hi Neville,

Sorry that didn't work out for you.

Let me restate the situation:
You have two or more servers that host a web service.
You are calling the web service from Pocket PC (.NET Compact Framework)
You are getting a WebException from only one of the servers.

If this is the correct situation it sounds to me like you have a security
issue or some other server configuration issue on the server. I would
definitely get one of the admins to look into the security with you.

If you still believe it to be a problem with the .NET Compact Framework,
please let me know so we can get it taken care of.

Good luck,

Tom Krueger
Microsoft Corporation
Program Manager
http://weblogs.asp.net/tom_krueger

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
D

Dominik Amon

Hi Neville!

I do have the exact problem as you have!
I can call a webservice only one time - even if its the same one - A
call of a second webservice i also get a protocol error and the response
stream is empty.

The interessting thing is that calling the webservice throw the docking
station of my ipaq h2210 it works - only if i'm connected using GPRS on
my mobile phone it crashes!

I have MS CF 1.0 SP2, i also guess it's an Microsoft Bug!

do you found a solution for your issue?


regards,
dominik

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

Dominik Amon

Hi Tom

it is a CompactFramefork bug! I've got the same problem

regards,
dominik

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
N

Neville Richardson

Hi

Yes there is a solution but I do not know how to replicate it. It's
something to do with server setups, try the following two HelloWorld web
service calls:

http://alpha.kahsystems.com/testservice/service1.asmx?HelloWorld
http://www.pocket-forms.com/testservice/service1.asmx?HelloWorld

These have exactly the same and code on the web service side and if I
call them both twice from a Smartphone app then the second fails on the
second call. The only difference is the server setups. I informed Tom
Krueger from Microsoft and www.DiscountASP.net the hosting party of the
second domain and they both have been unhelpful, if anyone can determine
what the difference is then let me know. I have full access to the first
(working) server at work and can give full details on its setup. Oh I do
know that both servers are running 2003 Server

Neville Richardson.


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

Dominik Amon

Hi Neville,

I will try those samples when i'm at home again.
Sounds interessting - I will deploy my application on a diffrent server.
Note: I'm using Windows2000 Server IIS5 using .net1.1 on the server
side.

If there is a setting and you figured out what setting it is, please let
me know.

I also contacted Tom Krueger yesterday afternoon (in Austria, thats
GMT+1).
He tried out my sample i deployed on my server and it worked, i also
deployed the dump file that my exception throws:

WebException thrown at 06.07.2004 23:33
========================
Message: WebException
Status: ProtocolError
ContentLength: 1510
ContentType: text/html; charset=utf-8
ResponseUri: http://www.amon.cc/Specials/Update.asmx
Header:
Server: Microsoft-IIS/5.0
Date: Tue, 06 Jul 2004 21:34:48 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 1510
X-Cache: MISS from uxboost3.mobilkom.at
Connection: close

ResponseTextLength: 0
ResponseText:

My mobile service provider (A1/vodaphone) will call me again to snif the
response stream

regards,
dominik



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

Dominik Amon

R

Richard Thombs

We had a problem that sounds like it was the same as what you were
experiencing. Our symptoms were this:

HOSTING ON A SHARED SERVER:
Connecting via ActiveSync - Worked fine.
Connecting via GPRS network #1 - 404 Not Found on the 2nd WebService call.
Connecting via GPRS network #2 - 404 Not Found on the 2nd WebService call.
Connecting via GPRS network #3 - Worked fine.

HOSTING ON A DEDICATED SERVER:
Connecting via ActiveSync - Worked fine.
Connecting via GPRS network #1 - Worked fine.
Connecting via GPRS network #2 - Worked fine.
Connecting via GPRS network #3 - Worked fine.

We came down the conclusion that the combination of ISP/Hosting
provider and some GPRS networks was causing the GPRS provider to cache
data when they most certainly should not be have been. Our hosting company
would not give us any details about what other network equipment our data
was travelling through, nor would they give us any information about the
server's main machine.config. We think they were adding some kind of
caching cues that they shouldn't have been and that this was tripping up
several of the GPRS networks we tested with.

For us, the solution was actually to switch hosting company. We had been
using a shared hosting provider while we were in the development phase of
our service. Once we switched, everything was fine!

Hope this helps,

Richard.
 
D

Dominik Amon

Hi Richard,

I have my own IIS on the net, well there are multiple websites on it,
but i guess there must be a special setting?

I can set the settings of the server for my own - but i should know WHAT
to set

dominik

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
R

Richard Thombs

I have my own IIS on the net, well there are multiple websites on it,
but i guess there must be a special setting?

I can set the settings of the server for my own - but i should know WHAT
to set

Unfortunately I never found out exactly what was going wrong. Maybe it was
a change in IIS configuration, maybe it was a change in some downstream
network box.

Our Windows 2003 server is an extremely standard setup, I didn't make any
special changes to get it working, it just worked as soon as I installed
it.

I'm really sorry I can't be more specific about what the solution was.
Maybe one day someone will figure it out!

Richard.
 
T

Tom Krueger [MSFT]

Neville,

I'm sorry that you feel I have been unhelpful, that was never my intention.
Since I did not notice a response post from you for my last post to you I
assumed everything was working for you. Just so you know, I am committed to
helping you figure out this problem. Since I don't want to publish my real
contact info, you (or anyone) can contact me directly through
http://weblogs.asp.net/tom_krueger/contact.aspx after which I will give you
my real email address and phone number.

Dominik, the other gentleman in this news thread had contacted me directly
and we have been trying to figure this out. He provided me a sample
application that called a Web Service which was not working for him. It
worked fine for me through the PPC 2002 Emulator, PPC 2003 Emulator, and on
a HP 4150 device (PPC). My last correspondence with him was asking him what
device / emulator he was using and also asking him to try it from a Windows
Forms applications.

Going back a bit, Neville, in your posts you mentioned that you had two web
servers. When you were calling one, it worked, and when you were calling
another it did not. This tells me that it is a server configuration issue.
From the information I have for your situation I would like to hear your
response to my last post to you. Here is what I wrote:
----------------------------------------------
Sorry that didn't work out for you.

Let me restate the situation:
You have two or more servers that host a web service.
You are calling the web service from Pocket PC (.NET Compact Framework)
You are getting a WebException from only one of the servers.

If this is the correct situation it sounds to me like you have a security
issue or some other server configuration issue on the server. I would
definitely get one of the admins to look into the security with you.

If you still believe it to be a problem with the .NET Compact Framework,
please let me know so we can get it taken care of.
----------------------------------------------

Please notice the situation that I restated, if there is anything different
about your situation, my response could very likely be different. In
addition to my response above, please be sure to try connecting to the web
services on both servers through a Windows Forms application to verify if it
is working that way. I know that in a previous post you mentioned that you
tried this, however, I want to make sure you are testing both your servers
from Windows Forms and not just the one that works.

I didn't want to make too many assumptions or jump to conclusions before
understanding the entire problem, however, I am thinking that (from the
information I have) it is possible this is an authentication issue. I could
see possibility that the Windows Forms application authenticates properly
but the Pocket PC application does not.

In comparing Dominik's problem with your problem there may or may not be any
correlation. As far as I know he is only using One web server and having a
problem where you are using Two web servers and getting the problem on Only
One of them. Again, you both could have the same issue, or totally
different ones. In Dominik's situation I get successful results with his
sample code testing against the same web service, so that tells me he is
either using a device I have not tried or there is some configuration on his
device that is incorrect. So once again, your issues could be totally
unrelated or they could be the same.

I am going to test the following Web Services now. In a way I hope that
they fail for me so I can begin fixing the problem.
http://alpha.kahsystems.com/testservice/service1.asmx?HelloWorld
http://www.pocket-forms.com/testservice/service1.asmx?HelloWorld

Committed to helping you solve this problem,

Tom







--
Tom Krueger
Microsoft Corporation
Program Manager
http://weblogs.asp.net/tom_krueger

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
T

Tom Krueger [MSFT]

Ok,

I have tested both of these Web Services and was able to successfully
connect mulitple times from the PPC 2002 emulator and SmartPhone 2003
(virtual radio) emulator.

http://alpha.kahsystems.com/testservice/service1.asmx?HelloWorld
http://www.pocket-forms.com/testservice/service1.asmx?HelloWorld

Let me know what devices you are using.

Tom

--
Tom Krueger
Microsoft Corporation
Program Manager
http://weblogs.asp.net/tom_krueger

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
R

Richard Thombs

I have tested both of these Web Services and was able to successfully
connect mulitple times from the PPC 2002 emulator and SmartPhone 2003
(virtual radio) emulator.

If I may add my 2c here, I believe the problem lies not in the device
itself, but in the fact that the GPRS network being used is
messing with data stream somehow and confusing the .NET framework.

When we were experiencing this problem, if we connected the same
'malfunctioning' device to the Internet via ActiveSync it would work fine.
When we made it connect via GPRS again, it would fail.

Richard.
 
S

Sandeep Prabhakar [MSFT]

GPRS is not very reliable and there have been issues with it closing
connections. .Net Compact should (atleast in theory) handle such losses of
connections by means of media sense and be able to recover from this. I
would suspect that this is the case here since it appears to work always
with active sync and with some GPRS networks

To get more information about the problem a couple of things could be done:

1. Can you write a native client-server application using winsock that uses
stream sockets and see if you can

transfer data between the device and the hosting web server consistently.
If this works we know that its

something with .net compact's handling of data that it is receiving.

2. Can you try out the following program and see what the output prints
out. This gives the error code that states why the web exception was caused
by accessing the response.StatusCode property.
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;

class AccessWebService
{
static void Main()
{
try
{
// Create the request object
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://www.pocket-forms.com/testservice/s
ervice1.asmx");

// Issue the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

// Read the content
StreamReader reader = new StreamReader(response.GetResponseStream(),
Encoding.ASCII);
string content = reader.ReadToEnd();

MessageBox.Show(content);

// Close the response
response.Close();
}
catch(WebException wex)
{
MessageBox.Show(wex.ToString());
// Check the status to see if there might be a response object
if(wex.Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse response = (HttpWebResponse)wex.Response;
MessageBox.Show("The protocol error returned was '" +
response.StatusCode.ToString() + "'.");
response.Close();
}
}
}
}

Thanks,
Sandy

This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Dominik Amon

Hi Sandeep!


I already developed a application using a WebRequest Object for a normal
website (not webservice) it works probebly.
If the problem would be the GPRS connection, the exact result with those two
webservice wouldn't be.


I'm using a diffrent mobile service provider as richard, but i have exactly
the same result with
http://alpha.kahsystems.com/testservice/service1.asmx
http://www.pocket-forms.com/testservice/service1.asmx

I will try your sample soon...

regards,
dominik

Mit freundlichen Gruessen,

Dominik Amon
www.amon.cc
 
S

Sandeep Prabhakar [MSFT]

Hi Dominik,

Just wanted to follow up on this issue. Have you had any luck with the
status code that is returned?

That's interesting that a web request works but not a web service request.
Does the call to the web service ever succeed even once? Are you able to
access the web service if you type in the url into a web browser?

Thanks,
Sandy

This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Dominik Amon

Hi Sandeep!
That's interesting that a web request works but not a web service request.
Does the call to the web service ever succeed even once? Are you able to
access the web service if you type in the url into a web browser?

Well i now have an application that's using a WebRequest und a WebService.

Yes, i can access the WebService (Asmx & WSDL file) with Pocket IE

I've not tried your sample yet, but will do!

dominik
PS: I have problems with other applications (Mobile ICQ) when i'm moving
(for example by train) then sometimes the session is lost, but this call
(WebService only single call) also fails when i'm not moving :-(
 
S

Sandeep Prabhakar [MSFT]

Does the call to the web service work when you are connected through other
networks? Active sync or ethernet for instance.

This is especially hard for us to debug since it appears that there are
many parameters here that we don't know about and it is difficult to get a
repro case for this. So please bear with my questions and we're working on
resolving the issue as soon as possible.

Thanks,
Sandy

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top