Dalexan
asked on
xmlHTTP Post gets Error 53 response
When posting data to a web server, I get an Error 53 more often than not. Problem is, I don't have a way to tell if the data was posted but the response was lost, or if the post itself never made it to the server. Can anyone clarify with certainty just what this error tells me? If the data did not make it, I want to try again...if it did, I really do not want duplicate entries, but how do I know?
The code I use is in vb.net 2010 and looks like this:
xmlHTTP = New MSXML2.XMLHTTP
xmlHTTP.open("POST", strURL, False)
xmlHTTP.setRequestHeader(" Content-Ty pe", strContentType)
orderForm.lblStatus.Text = "Checking Info >>>"
System.Windows.Forms.Appli cation.DoE vents()
xmlHTTP.send(strPost)
strResponse = xmlHTTP.responseText
The code I use is in vb.net 2010 and looks like this:
xmlHTTP = New MSXML2.XMLHTTP
xmlHTTP.open("POST", strURL, False)
xmlHTTP.setRequestHeader("
orderForm.lblStatus.Text = "Checking Info >>>"
System.Windows.Forms.Appli
xmlHTTP.send(strPost)
strResponse = xmlHTTP.responseText
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here is the full code we are using to post transactions:
Public Function SendAuthString(ByRef strURL As String, ByRef strPost As String, ByRef strContentType As String) As String
On Error GoTo ErrorTrap
Push("frmOrderPoint:SendAu thString(" & strURL & "," & strPost & "," & strContentType & ")")
LogFileEntry(Peek(), 5)
Dim iErr As Int16 = 0
Dim xmlHTTP As MSXML2.XMLHTTP
Dim strResponse As String = String.Empty
Dim strAddHead As String = String.Empty
Dim aURL() As String
If strContentType = "xCharge" Then
'commented out section
ElseIf strContentType = "Base64" Then
aURL = Split(strURL, "|")
xmlHTTP = New MSXML2.XMLHTTP
xmlHTTP.open("POST", aURL(0), False)
xmlHTTP.setRequestHeader(" Authorizat ion", "Basic " & EncodeBase64(aURL(1) & ":" & aURL(2)))
orderForm.lblStatus.Text = "Checking Info >>>"
System.Windows.Forms.Appli cation.DoE vents()
xmlHTTP.send(strPost)
strResponse = xmlHTTP.responseText
xmlHTTP = Nothing
Else
If strContentType = "" Then
strContentType = "application/x-www-form-ur lencoded"
End If
xmlHTTP = New MSXML2.XMLHTTP
xmlHTTP.open("POST", strURL, False)
xmlHTTP.setRequestHeader(" Content-Ty pe", strContentType)
orderForm.lblStatus.Text = "Checking Info >>>"
System.Windows.Forms.Appli cation.DoE vents()
xmlHTTP.send(strPost)
strResponse = xmlHTTP.responseText
xmlHTTP = Nothing
End If
SendAuthString = strResponse
ExitFunc:
Pop()
Exit Function
ErrorTrap:
iErr += 1
If Err.Number = 53 Then
If iErr < 3 Then
Pause(2)
Resume
End If
End If
GStr_f_end_method = Peek()
GLng_f_end_number = Err.Number
GStr_f_end_desc = Err.Description
ErrHandler_OP(frmOrderPoin t)
SendAuthString = ""
Resume ExitFunc
End Function
Public Function SendAuthString(ByRef strURL As String, ByRef strPost As String, ByRef strContentType As String) As String
On Error GoTo ErrorTrap
Push("frmOrderPoint:SendAu
LogFileEntry(Peek(), 5)
Dim iErr As Int16 = 0
Dim xmlHTTP As MSXML2.XMLHTTP
Dim strResponse As String = String.Empty
Dim strAddHead As String = String.Empty
Dim aURL() As String
If strContentType = "xCharge" Then
'commented out section
ElseIf strContentType = "Base64" Then
aURL = Split(strURL, "|")
xmlHTTP = New MSXML2.XMLHTTP
xmlHTTP.open("POST", aURL(0), False)
xmlHTTP.setRequestHeader("
orderForm.lblStatus.Text = "Checking Info >>>"
System.Windows.Forms.Appli
xmlHTTP.send(strPost)
strResponse = xmlHTTP.responseText
xmlHTTP = Nothing
Else
If strContentType = "" Then
strContentType = "application/x-www-form-ur
End If
xmlHTTP = New MSXML2.XMLHTTP
xmlHTTP.open("POST", strURL, False)
xmlHTTP.setRequestHeader("
orderForm.lblStatus.Text = "Checking Info >>>"
System.Windows.Forms.Appli
xmlHTTP.send(strPost)
strResponse = xmlHTTP.responseText
xmlHTTP = Nothing
End If
SendAuthString = strResponse
ExitFunc:
Pop()
Exit Function
ErrorTrap:
iErr += 1
If Err.Number = 53 Then
If iErr < 3 Then
Pause(2)
Resume
End If
End If
GStr_f_end_method = Peek()
GLng_f_end_number = Err.Number
GStr_f_end_desc = Err.Description
ErrHandler_OP(frmOrderPoin
SendAuthString = ""
Resume ExitFunc
End Function
Is strPost are any special characters parsed or escaped is that variable? Does a single-quote in that variable screw it up?
ASKER
No special characters or single quotes in that variable.
Did you try GET instead POST?
ASKER
Instead of troubleshooting this issue we decided to change our code to use the .dll instead of passing the parameters to the customers webservice. We will go forward under the assumption that not supporting msxml is a step in the wrong direction for our application and will pursue a more open source alternative.
ASKER
In my code (shown above) I get the Error 53 on the xmlHTTP.send(strPost) line.