I have code in VB6 that sends a web request to my server to pass and get data. Once upon a time it was working, but now it's not.
To be clear, this is used in a VB6 app that is distributed to my customers. It passes a webrequest to a web server that I fully control. I mention this because I think the problem is with how my server is configured, but I am not sure.
The VB6 code is this:
I did a considerable amount of research on this. On one site, someone suggested to create a vb script to mimic what is happening here. So I created this:
When I run the vbs on my computer (window 10), I get a positive response. When I run it from my windows XP compile computer, I get, "The connection with the server was terminated abnormally". I also get the same error message when I run the same web service call from PostMan.
Since the vbs works from some work stations and not others, I think it may be a combination problem between sending operating system and server configuration. The web server is Windows Server 2016 Standard, Version 1607 (OS Build 14393.5921).
I know I talked a lot about VBS, but the real solution needs to be done in VB6. I don't know the operating systems of all my customers, but I'm certain they are not all running WinXP. In fact, I suspect most are running Win10 or Win11.
Before someone suggests disabling anti-virus and/or running as administrator, I've done that already.
-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
To be clear, this is used in a VB6 app that is distributed to my customers. It passes a webrequest to a web server that I fully control. I mention this because I think the problem is with how my server is configured, but I am not sure.
The VB6 code is this:
Code:
Public Function Post(ByVal URL As String, ByVal Data As String) As String
Dim objDom As MSXML2.DOMDocument60
Dim objXmlHttp As MSXML2.ServerXMLHTTP60 ' MSXML2.XMLHTTP60
Dim strRet As String
On Error GoTo Err_PW
' Create objects to DOMDocument and XMLHTTP
Set objDom = New MSXML2.DOMDocument60 ' CreateObject("MSXML2.DOMDocument60")
Set objXmlHttp = New MSXML2.ServerXMLHTTP60 ' MSXML2.XMLHTTP60 ' CreateObject("MSXML2.XMLHTTP60")
' Load XML
objDom.async = False
With objXmlHttp
' Open the webservice
.Open "POST", URL, False
' Create headings
.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
.setRequestHeader "Content-Length", Len(Data) + 2
' Send XML command
.send Data
' Get all response text from webservice
strRet = .responseText
End With
' Close object
Set objXmlHttp = Nothing
' Return result
Post = strRet
Exit Function
Err_PW:
Post = "Error: " & Err.Number & " - " & Err.Description
End Function
I did a considerable amount of research on this. On one site, someone suggested to create a vb script to mimic what is happening here. So I created this:
Code:
strURL = "[URL unfurl="true"]https://apps.(my[/URL] product name).com/MapData/Data.asp?CustomerGuid=12942A91-2EAC-4B59-8D54-77A031434F1A&Mode=BulkGeocode"
strDataToSend = "<addresses><address id=""15910"" location=""160 LEE ROAD 4 LOACHAPOKA AL 36865""/></addresses>"
strPageText = GetResponseText(strURL, "POST", strDataToSend)
WScript.Echo strPageText
Function GetResponseText(strSource, strMethod, strData)
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.Open strMethod, strSource, False
objXMLHTTP.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
objXMLHTTP.send strData
GetResponseText = Trim(objXMLHTTP.responsetext)
Set objXMLHTTP = Nothing
End Function
When I run the vbs on my computer (window 10), I get a positive response. When I run it from my windows XP compile computer, I get, "The connection with the server was terminated abnormally". I also get the same error message when I run the same web service call from PostMan.
Since the vbs works from some work stations and not others, I think it may be a combination problem between sending operating system and server configuration. The web server is Windows Server 2016 Standard, Version 1607 (OS Build 14393.5921).
I know I talked a lot about VBS, but the real solution needs to be done in VB6. I don't know the operating systems of all my customers, but I'm certain they are not all running WinXP. In fact, I suspect most are running Win10 or Win11.
Before someone suggests disabling anti-virus and/or running as administrator, I've done that already.
-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom