Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Post to webservice with MSXML2 error

Status
Not open for further replies.

gmmastros

Programmer
Feb 15, 2005
14,900
0
36
US
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:

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
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Try replacing

[tt]Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")[/tt]

with

[tt]Set objXMLHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")[/tt]

The latter uses a different HTML stack that may work
 
strongm,

Thanks for the advice. Unfortunately, I get the same error.

Error: The connection with the server was terminated abnormally
Code: 80072EFE
Source: WinHttp.WinHttpRequest

I think you know what my product name is, so I was wondering if you had an opportunity to run the code and whether you get an error or a success response.

-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
 
>I think you know what my product name is

I do? If I did I've forgotten ...

In the meantime, what happens if you try HTTP rather than HTTPS?

Also you might want to try lying about the user agent ..

objXMLHTTP.setRequestHeader "User-Agent", "Chrome"
 
Windows XP is no longer supported. Thus its cipher suite was never upgraded to support current SSL/TLS technology.

The server was probably upgraded to use a current level of TLS ciphers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top