473,395 Members | 1,608 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,395 software developers and data experts.

httpWebrequest error

I am sending information to a webpage using the httpwebrequest object. When I
send a simple string (i.e. "message-test") it works fine. I changed it to
send an XML document by encoding it and adding it to the stream now I get an
internal 500 error when I try to get the response. Could you please let me
know what I am doing wrong. The code is as shown below.

Thanks

Dim objRequest As HttpWebRequest =
WebRequest.Create("http://localhost/VBWebPlayground/XMLTrans.aspx")
Dim XmlString As String

'Load XML into String
Dim docReader As System.IO.StreamReader = New
System.IO.StreamReader("c:\testinv2.xml")
XmlString = docReader.ReadToEnd()
docReader.Close()
' setup HTTP header
objRequest.ContentType = "application/x-www-form-urlencoded"
objRequest.KeepAlive = False
objRequest.Method = "POST"
objRequest.ProtocolVersion = HttpVersion.Version10

'encode XML document
Dim encXML As Byte() =
System.Text.Encoding.GetEncoding(1252).GetBytes(Xm lString)
objRequest.ContentLength = encXML.Length

'Send information to webpage via stream object
Dim stmWriter As System.IO.Stream = objRequest.GetRequestStream()
stmWriter.Write(encXML, 0, encXML.Length) 'XmlString) '&

Try
stmWriter.Close()
Catch exp As System.Exception
label1.Text = "Request=" & exp.Message
End Try

'Get response stream to complete transmition
Dim rsp As HttpWebResponse
Try
rsp = objRequest.GetResponse()
Catch exp As System.Exception
label1.Text = "Response=" & exp.Message
End Try
Jul 28 '05 #1
0 945

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

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
3
by: Jason | last post by:
I'm having a hard time getting a call to HttpWebRequest's GetRequestSteam to work. Each time I try to run it, I get the following error: The underlying connection was closed: Unable to...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
2
by: =?Utf-8?B?TGFycnlLdXBlcm1hbg==?= | last post by:
Our WebDev team seems to have found a problem that exposes a bug in .NET 2.0. This problem can be shown when trying to access a WebService using SSL and through a proxy server after using the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.