I am supposed to code an application to talk to AS400... before i send the data i will convert it to "Cp1047" but when it reaches AS400 its appears to in HEX.
Any one can spare me some clue what am i doing wrong here?
Desire result: f0f2f9f9f44040404040f0f0f1f6f6f8f1f6f0f9c3c3f...
Current result: 30323139 30202020 20203032 35313037...
Franky John wrote:print out of Arrays.toString(messageValue)
[-16, -14, -7, -7, -12, 64, 64, 64, 64, 64, -16, -16, -15, -10, -10, -8, -15, -10, -16, -7, -61, -61, -11, -8, -14, -14, -14, -60, -7, -10, -9, -62, 75, -14, -16, -13]
There is some ambiguity with regards to which computer prints this but if I run :-
then I get
which implies that the result
is nothing to do with the value sent.
:-) Of course it could be that I have the wrong end of the stick!
Note - the values 30323139 30202020 20203032 35313037... look to be just hex encoded ASCII decimal digits and spaces.
Franky John wrote:Forgot to mention that its from Window to AS400... and the receiving end is not done me. All i know is that its in C the data sent has to be in EBCDIC
We understood that from the "Cp1047" BUT I don't think that is the whole story. You only need to convert to "Cp1047" if you are sending characters but I suspect that you should actually just be sending bytes without any encoding. Certainly the AS400 values do not look like EBCDIC characters since many have the most significant bit set. Bytes on the AS400 are bytes on Windows are bytes on Linux are bytes on any platform. The "Cp1047" encoding only becomes relevant if those bytes are interpreted as characters and I don't think the values you have posted should be interpreted as characters.
Without you actually posting the sending code we can do little to help you. If you could show both the C on the AS400 and your Java I'm sure I and many others here could help.
Basically what happen is that i have FUNCTIONX() which returns a String after processing the request.
then pass into a send message function.
1) The 'Message' string,
2) The hex encoded 'messageValue',
3) The hex encoded 'len'
4) The hex encoded 'temp'.
and post the values.
I don't think you should be getting the OutputStream from the socket each call to sendMessage. I think you should be passing in the OutputStream and writing to that directly.
You don't need the flush() before writing 'temp'. The flush() afterwards is required.
I would be very very very surprised if the hex encoded value of 'temp' looks anything like the value you posted as your required received value in your C code. I think you are sending the wrong data.
Message sent (in EBCDIC) :f0f2f9f9f44040404040f0f0f1f6f6f8f1f6f0f9c3c3f5f8f2f2f2c4f9f6f7c24bf2f0f3...
Overall in hex 0024f0f2f9f9f44040404040f0f0f1f6f6f8f1f6f0f9c3c3f5f8f2f2f2c4f9f6f7c24bf2f0f3...
note: 0024 is the string length and need not be in EBCDIC format but in binary hex