Web client error i get (internal server error 500)

  • Thread starter Thread starter Atul Mittal
  • Start date Start date
A

Atul Mittal

hi i am trying to use webclient methoid to transfer an XML string from
one server to other .... below is my coding paste
whenever i am doing an mywebclient.upload i get an error
internal server errror 500
any ideas what is the problem
both the servers are on same domain.
plzz help .... plzzzzz



Public Function xmlstrsend(ByVal redirectURL As String, ByVal xmlstr As
String) As String
Dim uriString As String

uriString = redirectURL
' Create a new WebClient instance.
Dim myWebClient As New WebClient

Dim postData As String = xmlstr
myWebClient.Headers.Add("Content-Type",
"application/x-www-form-urlencoded")

' Apply ASCII Encoding to obtain the string as a byte array.
Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData)

' Upload the input string using the HTTP 1.0 POST method.
Dim responseArray As Byte() = myWebClient.UploadData(uriString,
"POST", byteArray)
' Decode and display the response.
Dim returnxmlstr As String
returnxmlstr = Encoding.ASCII.GetString(responseArray)
Return returnxmlstr
End Function
 
Atul said:
hi i am trying to use webclient methoid to transfer an XML string
from one server to other .... below is my coding paste
whenever i am doing an mywebclient.upload i get an error
internal server errror 500
any ideas what is the problem
both the servers are on same domain.
plzz help .... plzzzzz



Public Function xmlstrsend(ByVal redirectURL As String, ByVal xmlstr
As String) As String
Dim uriString As String

uriString = redirectURL
' Create a new WebClient instance.
Dim myWebClient As New WebClient

Dim postData As String = xmlstr
myWebClient.Headers.Add("Content-Type",
"application/x-www-form-urlencoded")

' Apply ASCII Encoding to obtain the string as a byte array.
Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData)

' Upload the input string using the HTTP 1.0 POST method.
Dim responseArray As Byte() = myWebClient.UploadData(uriString,
"POST", byteArray)
' Decode and display the response.
Dim returnxmlstr As String
returnxmlstr = Encoding.ASCII.GetString(responseArray)
Return returnxmlstr
End Function

Quite franky, there's a lot in that code that could go wrong.

1.
First of all, all HTTP input/output is based on ASCII encoding. That is
neither a proper encoding for XML nor for HTTP responses. Could work,
could break.

2.
Is application/x-www-form-urlencoded really what you want to use? If you
want to upload a file, that should be "text/xml". Otherwise, your
submitted xml string must be a key/value pair in order to be processed
properly by the receiving web application.

Cheers,
 
Back
Top