Bonjour
j'essaie de traduire le texte ci-dessous en vb.net mais ca ne fonctionne pas, pas d'erreur de compilation mais le serveur ne reçoit rien

The Payment Terminal uses utf-8 encoding.
Basic message transport information is added to the XML messages shown in this chapter. In order to send and receive variable length XML messages a simple message header indicating the overall length of the message must be used.
The XML messages starts with a 4 Byte unsigned integer used as length indicator (big endian format, i.e. most significant byte first). There is no 0x00 at the end of the message included.
The XML message below has a length of 544 characters when converted to bytes.

Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="utf-8"?>
<CardServiceRequest WorkstationID="POS" RequestID="205" RequestType="CardPayment" xmlns="http://www.nrf-arts.org/IXRetail/namespace">
<POSdata LanguageCode="nl">
<POSTimeStamp>2015-09-16T14:08:34.8279797+02:00</POSTimeStamp>
<ShiftNumber>0</ShiftNumber>
<PrinterStatus>Available</PrinterStatus>
<E-JournalStatus>Available</E-JournalStatus>
</POSdata>
<TotalAmount Currency="EUR">0.01</TotalAmount>
<CardCircuitCollection>
</CardCircuitCollection>
</CardServiceRequest>


This length of this message is 544 bytes and will be preceded by a 4 bytes length: 00 00 02 20 (= 544 decimal)
The whole message will look like:

000000: 0000 0220 3c3f 786d 6c20 7665 7273 696f      ... <?xml versio
000010: 6e3d 2231 2e30 2220 656e 636f 6469 6e67     n="1.0" encoding
000020: 3d22 7574 662d 3822 3f3e 0d0a 3c43 6172     ="utf-8"?>..<Car
000030: 6453 6572 7669 6365 5265 7175 6573 7420     dServiceRequest
000040: 576f 726b 7374 6174 696f 6e49 443d 2250     WorkstationID="P
000050: 4f53 2220 5265 7175 6573 7449 443d 2232    OS" RequestID="2
000060: 3035 2220 5265 7175 6573 7454 7970 653d    05" RequestType=
000070: 2243 6172 6450 6179 6d65 6e74 2220 786d    "CardPayment" xm
000080: 6c6e 733d 2268 7474 703a 2f2f 7777 772e      lns="http://www.
000090: 6e72 662d 6172 7473 2e6f 7267 2f49 5852      nrf-arts.org/IXR
0000a0: 6574 6169 6c2f 6e61 6d65 7370 6163 6522     etail/namespace"
0000b0: 3e0d 0a20 203c 504f 5364 6174 6120 4c61     >.. <POSdata La
0000c0: 6e67 7561 6765 436f 6465 3d22 6e6c 223e     nguageCode="nl">
0000d0: 0d0a 2020 2020 3c50 4f53 5469 6d65 5374     .. <POSTimeSt
0000e0: 616d 703e 3230 3135 2d30 392d 3136 5431     amp>2015-09-16T1
0000f0: 343a 3038 3a33 342e 3832 3739 3739 372b     4:08:34.8279797+
000100: 3032 3a30 303c 2f50 4f53 5469 6d65 5374      02:00</POSTimeSt
000110: 616d 703e 0d0a 2020 2020 3c53 6869 6674    amp>.. <Shift

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
            Dim SizeMSG As UInt32 = 544 ' EXEMPLE : longueur du MESSAGE a envoyer
            Dim HEADER = ChrW(&H1) & SizeMSG   ' ChrW(&H1) = SOH -> unicode header ( alt+001 )
            Dim vecteur1As Byte() = System.Text.Encoding.BigEndianUnicode.GetBytes(HEADER)
 
            Dim vecteur2 As Byte() = System.Text.Encoding.UTF8.GetBytes("MESSAGE XML A ENVOYER")
 
            Dim COPYTAB As Byte()
            ReDim COPYTAB(vecteur1.Length + vecteur2.Length) 
            System.Array.Copy(vecteur1, 0, COPYTAB, 0, vecteur.Length)
            System.Array.Copy(vecteur2, 0, COPYTAB, vecteur.Length, vecteur2.Length)
 
           Dim client As New System.Net.Sockets.TcpClient()
           client = New System.Net.Sockets.TcpClient
           client.Connect(IP, port)
 
          Dim sendStream As NetworkStream = client.GetStream()
          sendStream .Write(COPYTAB, 0, COPYTAB.Length)
          sendStream .Flush()

Ai je bien fait ???

Merci d'avance pour votre aide