473,320 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with HttpWebRequest class...

I'm trying to use the HttpWebRequest class to retrieve XML generated by a
jsp page, but an 'The remote server returned an error: (500) Internal Server
Error' exception is thrown when I call the WebRequest's GetResponse()
method. If I type the URL into the browser (IE), the correct XML is
returned. Similarly, the correct XML is returned if I open the URL using the
WebClient class' OpenRead() method. Here's the code that I'm using:

//The following code results in the exception:
string strURL =
"http://serverName/appDir/filename.jsp?accountName=acc&strParam=param1";
System.Uri myURI = new System.Uri(strURL, false); //I've also tried
setting the second parameter to 'true'.
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(myURI);
myRequest.Method = "GET";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.Accept = "*/*";
myRequest.Timeout = 30000;
myRequest.CookieContainer = m_cookieContainer; //Setting this in order
to pass same session id to server.
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
//Exception is thrown here.
StreamReader myReader = new
StreamReader(myResponse.GetResponseStream());
string strResponse = myReader.ReadToEnd();
myResponse.Close();
myReader.Close();

//The following code works correctly:
System.Net.WebClient wc = new WebClient();
string strURL =
"http://serverName/appDir/filename.jsp?accountName=acc&strParam=param1";
System.IO.Stream myStream = wc.OpenRead(strURL);
StreamReader myReader = new StreamReader(myStream);
string s = myReader.ReadToEnd();
myStream.Close();
myReader.Close();

Any ideas would be greatly appreciated.

Darryl R.
Nov 18 '05 #1
0 837

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: TJO | last post by:
Can someone at MS please reply to this. I am trying to post data so a web form via ssl with the following code. I keep getting this error: "The underlying connection was closed: Could not...
0
by: Darryl | last post by:
I'm trying to use the HttpWebRequest class to retrieve XML generated by a jsp page, but an 'The remote server returned an error: (500) Internal Server Error' exception is thrown when I call the...
2
by: news.microsoft.com | last post by:
Hello I try to implement "retry" if connection to web ends with "time out". I want to give a chance to prolong waiting for response. The following code is taken from WebRequest.GetResponse()...
11
by: Keith Patrick | last post by:
Could someone explain to me the relationship between these two classes? I am ripping my hair out trying to divert an HttpRequest to a new location via an HttpWebRequest, but I cannot get my...
1
by: sfoxover | last post by:
Hi, Could someone please give me some suggestions on how to make this class robust. I need to be able to handle around 20 similtanious requests to this class which causes a web browser to...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
1
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've...
8
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've...
1
by: Kevin Landymore | last post by:
I have a vb.net service running under a Domain account. I'm trying to call a web service on our Mainframe (IBM CICS via SSL and Client Certificates) and after a while (1 or 2 days.. thousands of...
0
by: Alok yadav | last post by:
i am using the link of metacharge.com for payment gateway, when i post data throung IE it give the correct response, but when i use the .net code to post data the response is not correct.message is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.