Soap body - utf-8 encoded twice

We are using a web service that expects UTF-8. The framework we are using on the client is Apache Axis2. We call the web service and the soap body contains strings in UTF-8. The problem is that the body appears to be "double-encoded". I. We have a "å" symbol. The utf-8 representation 'å' in utf-8 is C3 A5, however, in our logs, we can see that the sent (double) encoded value is C3 83 C2 A5.

Has anyone faced similar issues?

0


a source to share


1 answer


It is not entirely clear how you call the web service. Does the method in the web service use a string? If so, what does your string look like in Java? All strings in Java are UTF-16 encoded - if you are converting the UTF-8 binary representation to a string, taking each byte and converting it to a character, then this is a problem.

If you could show what the method you are calling looks like and what you call it, that would help a lot.

For what it's worth, I've used Axis with non-ASCII strings with no problem in the past. I strongly suspect that this is a problem with the way you use it and not with Axis itself, although I am prepared to be wrong :)



EDIT: Based on your comment, it seems like you were having trouble getting the HTML form data before you hit the web service. If the user typed "å" into the form, this is what you should see when debugging in Eclipse. If you're putting bad data into your web service, it's no surprise that you get bad data on the other end. I suggest you run WireShark to see exactly what the browser is sending you, both in terms of raw bytes and with which content encoding the master. I am assuming your webserver is treating it as ISO-8859-1, but it is actually UTF-8.

Once you've got the line out of the form correctly, I suspect you'll find that there is no problem in submitting it to the web service.

+1


a source







All Articles