1

I need to send Thai characters as part of a json REST request which will be sent to a SOAP webservice.

This is the json request:

{
    "thaiDesc": "ฃ ขวด"
}

When I log this string on the server side, it is getting converted to question mark:

utf8EncodedString: ? ???

This is the code i used to encode the thai characters:

String rawString =request.getThaiDesc();
byte[] bytes = rawString.getBytes(StandardCharsets.UTF_8);
String utf8EncodedString = new String(bytes, StandardCharsets.UTF_8);

In the SOAP Webservice Request, the UTF-8 HEX is being sent instead:

<TH_DESC>[0xe0][0xb8][0x83] [0xe0][0xb8][0x82][0xe0][0xb8][0xa7][0xe0][0xb8][0x94]</TH_DESC>

Can somebody please advise how to send the original thai characters to the SOAP Webservice instead?

Yassin Hajaj
  • 21,337
  • 9
  • 51
  • 89
nooruto
  • 13
  • 1
  • 4
  • 1
    (1) SOAP uses XML, not JSON. If you pass JSON to a SOAP service, I imagine it will fail immediately. (2) Your last two lines of code are meaningless. You are converting a String to UTF-8 bytes, then creating a String from UTF-8 bytes: it’s a pointless round trip. Remove those two lines. (3) How are you sending the request? Are you being careful to encode the request as UTF-8? (4) What does “UTF-8 HEX” mean? Are the first six characters literally `[`, `0`, `x`, `e`, `0`, `]`? – VGR Apr 10 '21 at 21:44
  • (1) The JSON request is sent using a REST webservice, then I pass the request to the SOAP objects generated from the wsdl file resulting in successful SOAP call (3) FYI [UTF-8 HEX](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=3584&number=128&utf8=0x) (4) I pasted the exact request, it is not comma separated like you assumed – nooruto Apr 10 '21 at 22:16
  • I did not assume commas. I am asking whether you are sending a `[` character. – VGR Apr 10 '21 at 23:06
  • Side note: Question marks such as `? ???` - This issue has been discussed here before - for example, [this](https://stackoverflow.com/questions/19038353/why-appears-as-output-while-printing-unicode-characters-in-java) or [this](https://stackoverflow.com/questions/217237/what-does-it-mean-when-my-text-is-displayed-as-question-marks) or various others. The `?` is either a literal `?` or (in your case) a replacement for the actual symbol/glyph which cannot be displayed in the character encoding being used - in this case, the character encoding used for logging. – andrewJames Apr 11 '21 at 00:59

0 Answers0