I have recently taken over a legacy service and I'm in the process of converting it to PHP, however I have gotten stuck with the more intricate functionality of C#.
From what I see the request message length needs to be packed and then concatted with the actual message before being sent to the service.
string strReceiveBuffer;
string msg1 = string.Empty;
msg1 = msg1 + txtRqst.Text;
Int64 intMessageLength = msg1.Length;
byte byt1; byte byt2;
//The below should work assuming a 16 bit register.
byt1 = Convert.ToByte(decimal.Truncate(intMessageLength/ 256));
byt2 = Convert.ToByte(decimal.Remainder(intMessageLength, 256));
string strLength = string.Empty;
strLength = strLength
+ Microsoft.VisualBasic.Strings.Chr(byt1).ToString()
+ Microsoft.VisualBasic.Strings.Chr(byt2).ToString();
//Only encode the length using BigEndianCode, the message content is encoded using UTF8
byte[] byteData = Encoding.BigEndianUnicode.GetBytes(strLength)
.Concat(Encoding.UTF8.GetBytes(msg1)).ToArray();
Is anybody able to help with the above code before I tear my hair out?