Send POST and then Recive XML - system.net.WebRequest

I need to be able to do this

POST /servlet/MainVCAServlet HTTP/1.0
Content-Type: text/xml
User-Agent: xLinkClient
Content-length: 544

<?xml version="1.0" standalone="no"?>
<!DOCTYPE request SYSTEM "http://xapi.covad.com/dtd/request.dtd">
<request>
<header>
<sender>
<key>
<login>YOUR LOGIN ID</login>
<password>YOUR PASSWORD</password>
</key>
</sender>
</header>
<body>
<subrequest type="serviceavailability">
<serviceavailabilityrequest>
<address>
<street1>1016 Asbury Way</street1>
<city>Mountain View</city>
<state>CA</state>
<zip>94043</zip>
</address>
</serviceavailabilityrequest>
</subrequest>
</body>
</request>

I am thinking it can be done with system.net.WebRequest
LVL 1
VartanaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Bob LearnedConnect With a Mentor Commented:
0
 
Bob LearnedCommented:
Yes, you should be able to do this.  Have you started with any code?  Do you know how to form a web request?

Bob
0
 
VartanaAuthor Commented:
no I dont know how to use it ?
0
 
VartanaAuthor Commented:
Dim myRequest As WebRequest = WebRequest.Create("http://staging.mileg.org/testapp/form2.asp")
Dim strPost As String = "textbox=simon"
MessageBox.Show(myRequest.RequestUri.ToString)myRequest.Method = "post"
myRequest.ContentLength = strPost.Length
myRequest.ContentType = "application/x-www-form-urlencoded"
Dim mystreamwriter As New StreamWriter(myRequest.GetRequestStream)
mystreamwriter.Write(strPost)
mystreamwriter.Close()
MessageBox.Show(myRequest.RequestUri.ToString)

' Return the response.
Dim myResponse As WebResponse = myRequest.GetResponse
Dim mystream As Stream = myResponse.GetResponseStream
Dim mystreamreader As New StreamReader(mystream)
Do Until mystreamreader.Peek = -1
TextBox1.Text += (mystreamreader.ReadLine.ToString())
Loop
mystreamreader.Close()
mystream.Close()
0
 
Bob LearnedCommented:
0
All Courses

From novice to tech pro — start learning today.