Hi
Trying to get this code to work for http xml post.
I need the post to be xml (doc.outerxml) sent in single key name as stream.
The following is the post code and code for receiving the request.
When it hits the "myresponse = myrequest.GetRe sponse()" in the post code -
I'm getting following error:
"The remote server returned an error: (500) Internal Server Error".
I don't know if I have something wrong with the post or receiving it on the
other end.
Right now I'm trying to write it in .net 1.1.
Any help will be greatly appreciated.
Thanks,
Cindy
Dim url As String = "http://someplace.aspx"
Dim myrequest As System.Net.WebR equest = Nothing
Dim myresponse As System.Net.WebR esponse = Nothing
Try
' Create a request using a URL that can receive a post.
myrequest = System.Net.WebR equest.Create(u rl)
' Set the Method property of the request to POST.
myrequest.Metho d = "POST"
' Set the ContentType property of the WebRequest.
myrequest.Conte ntType = "applicatio n/x-www-form-urlencoded"
' Create POST data and convert it to a byte array.
Dim vxml = "Interface_ 2=" + HttpUtility.Url Encode(Doc.Oute rXml)
Dim byteArray As Byte() =
System.Text.Enc oding.UTF8.GetB ytes(vxml)
' Set the ContentLength property of the WebRequest.
myrequest.Conte ntLength = byteArray.Lengt h
' Get the request stream.
Dim dataStream As System.io.Strea m =
myrequest.GetRe questStream()
' Write the data to the request stream.
dataStream.Writ e(byteArray, 0, byteArray.Lengt h)
' Close the Stream object.
dataStream.Clos e()
' Get the response.
myresponse = myrequest.GetRe sponse() 'error occurs here
Catch ex As Exception
Throw ex
Finally
' Closed streams
If Not myrequest Is Nothing Then
myrequest.GetRe questStream().C lose()
If Not myresponse Is Nothing Then
myresponse.GetR esponseStream() .Close()
End Try
Code for receiving the post:
Dim strReader As System.IO.Strin gReader = Nothing
Dim Reader As System.Xml.XmlT extReader = Nothing
Response.Conten tType = "applicatio n/x-www-form-urlencoded"
Response.Clear( )
Try
strReader = New
System.IO.Strin gReader(Request .Form("Interfac e_2"))
Reader = New System.Xml.XmlT extReader(strRe ader)
Do While Reader.Read()
Trying to get this code to work for http xml post.
I need the post to be xml (doc.outerxml) sent in single key name as stream.
The following is the post code and code for receiving the request.
When it hits the "myresponse = myrequest.GetRe sponse()" in the post code -
I'm getting following error:
"The remote server returned an error: (500) Internal Server Error".
I don't know if I have something wrong with the post or receiving it on the
other end.
Right now I'm trying to write it in .net 1.1.
Any help will be greatly appreciated.
Thanks,
Cindy
Dim url As String = "http://someplace.aspx"
Dim myrequest As System.Net.WebR equest = Nothing
Dim myresponse As System.Net.WebR esponse = Nothing
Try
' Create a request using a URL that can receive a post.
myrequest = System.Net.WebR equest.Create(u rl)
' Set the Method property of the request to POST.
myrequest.Metho d = "POST"
' Set the ContentType property of the WebRequest.
myrequest.Conte ntType = "applicatio n/x-www-form-urlencoded"
' Create POST data and convert it to a byte array.
Dim vxml = "Interface_ 2=" + HttpUtility.Url Encode(Doc.Oute rXml)
Dim byteArray As Byte() =
System.Text.Enc oding.UTF8.GetB ytes(vxml)
' Set the ContentLength property of the WebRequest.
myrequest.Conte ntLength = byteArray.Lengt h
' Get the request stream.
Dim dataStream As System.io.Strea m =
myrequest.GetRe questStream()
' Write the data to the request stream.
dataStream.Writ e(byteArray, 0, byteArray.Lengt h)
' Close the Stream object.
dataStream.Clos e()
' Get the response.
myresponse = myrequest.GetRe sponse() 'error occurs here
Catch ex As Exception
Throw ex
Finally
' Closed streams
If Not myrequest Is Nothing Then
myrequest.GetRe questStream().C lose()
If Not myresponse Is Nothing Then
myresponse.GetR esponseStream() .Close()
End Try
Code for receiving the post:
Dim strReader As System.IO.Strin gReader = Nothing
Dim Reader As System.Xml.XmlT extReader = Nothing
Response.Conten tType = "applicatio n/x-www-form-urlencoded"
Response.Clear( )
Try
strReader = New
System.IO.Strin gReader(Request .Form("Interfac e_2"))
Reader = New System.Xml.XmlT extReader(strRe ader)
Do While Reader.Read()
Comment