473,396 Members | 1,770 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,396 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.
Jul 21 '05 #1
0 1168

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

Similar topics

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()...
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." ...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.