Search code examples
jsonvb6responsetextserverxmlhttp

Missing responseText Information (vb6 call)


This problem has been driving me crazy, hopefully someone out there knows the answer as I couldn't find one searching around.

I am trying to access a web service in one of our legacy vb6 apps with the following:

Dim xmlHttpRequest As MSXML2.ServerXMLHTTP
Dim xmlParameters As String
Dim timeOutValue As Long

timeOutValue = 300 * 1000&
xmlParameters = "TradingPartnerName=" + inTradingPartnerName
Set xmlHttpRequest = New MSXML2.ServerXMLHTTP
xmlHttpRequest.Open "POST", urlString, False
xmlHttpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlHttpRequest.setRequestHeader "Host", "xa-2k8:2016/"
xmlHttpRequest.setTimeouts timeOutValue, timeOutValue, timeOutValue, timeOutValue

xmlHttpRequest.sEnd (xmlParameters)

It essentially makes the api call with the parameter "TradingPartnerName" with a value (in this case "DSSI"). It will then return a JSON result which gets parsed out later on.

What I get back from looking at wireshark is the following:

WireShark results

All of the right data is there...

When I look at xmlHttpRequest.responseText after the send (or decode .responseBody) I get the following:

ResponseText : "{"$id":"1","TradingPartnerInformation":{"$id":"2","$values":[{"$id":"3","TradingPartnerKey":1,"TpName":"DSSI","SenderIdQualifier":"12","SenderId":"(removed)","ReceiverIdQualif"

It truncates at 429 char's every time

Here is the content type being sent back: Content-Type → application/json; charset=utf-8

Am I doing something wrong? Or is it a bug in the library? I also tried with WinHTTP 5.1 and got the exact result.

From all the other examples I saw on stackoverflow, people were missing data in their wireshark analysis as well. In my case, I see all the right data being returned, so I just don't get why it is getting truncated.

Thanks in advance for any help with this!

EDIT: I played with the encoding digging deeper into GSerg's suggestion... and found using different decode types has different results when I convert responseBody from binary to a string.

With the following method:

Function BinaryToString(ByVal Binary)
    BinaryToString = ""
    Dim BinaryStream
    Set BinaryStream = CreateObject("ADODB.Stream")

    BinaryStream.Type = 1 '--- adTypeBinary

    BinaryStream.Open
    BinaryStream.Write Binary

    BinaryStream.Position = 0
    BinaryStream.Type = 2 '--- adTypeText

    BinaryStream.Charset = (UTF-8 or ASCII)

    BinaryToString = BinaryStream.ReadText
End Function

If I make the charset "UTF-8" I get the following:

"{"$id":"1","TradingPartnerInformation":{"$id":"2","$values":[{"$id":"3","TradingPartnerKey":1,"TpName":"DSSI","SenderIdQualifier":"12","SenderId":"(removed)","ReceiverIdQua

If I make the charset "ASCII" I get the following:

"{"$id":"1","TradingPartnerInformation":{"$id":"2","$values":[{"$id":"3","TradingPartnerKey":1,"TpName":"DSSI","SenderIdQualifier":"12","SenderId":"(removed)","ReceiverIdQualifier":"12","ReceiverId":"(removed)","ElementSeparator":"*","SubElementSea"

So, it seems it is an encoding problem, but still not getting the full result set when switching to ASCII


Solution

  • It was a limitation of the vb6 debugger itself. It was not displaying the full response even though it was in fact there if I outputted to a message box or file.

    Using MSXML2.ServerXMLHTTP to access data from a web page returns truncated data in Lua helped draw this conclusion