Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Xml
Message
From
04/08/2008 11:07:59
 
 
To
All
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Xml
Miscellaneous
Thread ID:
01336241
Message ID:
01336241
Views:
44
Hello All,

I have a question related to XML, I didn't know what Forum I should post my XML quesiton to so I thought I would start with this one.

I have an application that I am working that communicates to a VID (Server) using the Microsoft Winsock control by way of TCP/IP and the strings that are passed back and forth are in XML format.

One of the things that I have to do is synchronize the date and time of the Client with that of the Server. So I build up my XML string at the Client end requesting the Data and Time and send it off to the Server and I know (from viewing a log file at the Server end) that the Server receives it.

The problem that I am having is that I am only getting part of the string back from the Server. The log file at the Server end shows the string that was sent to the Client and is complete, but the Client only recieves part of the string.

The XML string that the Server sent (that appears in the Log file) is as follows:
<?xml version="1.0" encoding="GBK"?>
<Message Device="12345">
<Respond Name="GetTime">
<Row>
<Result>1</Result>
<ErrorMessage>Chinese characters are in here</ErrorMessage>
<DateTime>2008-08-04 06:57:41 AM</DateTime>
</Row>
</Respond>
</Message>
Please note that between
<ErrorMessage> </ErrorMessage>
are chinese characters

I display the string that I recieved from the Server in a message box at the Client end and is as follows:
<?xml version="1.0" encoding="GBK"?>
<Message Device="12345">
<Respond Name="GetTime">
<Row>
<Result>1</Result>
<ErrorMessage>"
Please note that evrything after
<ErrorMessage>
is not there, it appears as though the Client is chocking on the chinese characters.

I am using a DLL that someone else wrote for me that wraps the Winsock control. The code for the DataArrival event is as follows:
Private Sub pSocket_DataArrival(ByVal bytesTotal As Long)
    
    'MsgBox "Event: DataArrival"
    
    Dim DataAsByteArray As Variant
    Dim DataAsString As String
    Dim ByteArray() As Byte
    Dim NumBytes As Long
    Dim I As Long
    
    pSocket.GetData DataAsByteArray, (vbArray + vbByte)
    
    ByteArray = DataAsByteArray
    NumBytes = (UBound(ByteArray, 1) + 1)  'Array<-Variant makes the array start at 0...
    
    DataAsString = ""
    For I = 0 To (NumBytes - 1)
        DataAsString = DataAsString + Chr$(ByteArray(I))
    Next
    
    RaiseEvent RXedData(NumBytes, DataAsByteArray, DataAsString)
    
End Sub
Please note that there is an event called "RXedData" that I use in the Client to see what data is returned to me.

Is there a chance that there might be an issue with the code in the DataArrival event of the Winsock Control?

Perhaps the data retrieved in the GetData method should be "vbString" and not "vbArray + vbByte". I am thinking
that maybe the type of "vbArray + vbByte" does not support chinese characters and that "vbString" does!

I hope that I have explained my situation clearly and that someone know what I am doing wrong.

Thank You

Gary
Reply
Map
View

Click here to load this message in the networking platform