473,385 Members | 1,546 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,385 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 944

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...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.