You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by Wouter Cloetens <wc...@raleigh.ibm.com> on 2000/09/08 11:48:30 UTC
Re: SOAP UNICODE UTF-8 strings
On Fri, 8 Sep 2000 11:56:41 -0400, pmaenner@kodak.com wrote:
>SOAP 2.0 isn't consistent in its use of the UNICODE UTF-8 character
>encoding. The SOAP
>spec at http://www.w3.org/TR/SOAP doesn't actually come out and say that
>UTF-8 encoding
>shall be used, but every example in the spec uses it, and it is a good idea
>to do so.
>
>RPCRouterServlet.java uses UTF-8 to write it's response:
>
>line 134: res.setContentType (Constants.HEADERVAL_CONTENT_TYPE_UTF8);
>line 142: PrintWriter out = new PrintWriter (new OutputStreamWriter
>(bytes, "UTF8"),
>(UTF8 in line 142 should be spelt UTF-8)
Java 1.1's mappings only support "UTF8", not "UTF-8" as a codepage identifier. This value
is not used in output anywhere. The Content-Type is set to "UTF-8" correctly.
>however, SOAPHTTPConnection.java uses HEADERVAL_CONTENT_TYPE rather than
>HEADERVAL_CONTENT_TYPE_UTF8, so most likely US-ASCII is being defaulted to.
>
>line 108: HTTPUtils.Response response = HTTPUtils.post (sendTo,
>headers,
>line 109: Constants.HEADERVAL_CONTENT_TYPE,
>line 110: payloadSW.toString ());
>
>and the HTTPUtils.java post() method doesn't specify UTF-8:
>line 123: out = new PrintWriter (s.getOutputStream ());
>
>should be instead:
>line 123: out = new PrintWriter (new
>OutputStreamWriter(s.getOutputStream (), "UTF-8"));
You're right, the client side doesn't do UTF-8. My own patched version of Apache-SOAP, in
which I implemented codepage support around the same time as the base project, does
do this. It also supports all other Mime types, both on the client and the server side. I'm
considerably out of sync with the main project, though, and my code has some
dependencies which should be eliminated first (wish I had the time).
Specifically, I use JavaMail's javax.mail.internet.MimeUtility's javaCharset() and
mimeCharset() to convert from mime character set identifiers to java codepage ids. It
comes with a mapping table to take care of the UTF-8 <-> UTF8 etc issue.
bfn, Wouter
--
http://www.workspot.net/~zombie/soap/
My opinions are irrelevant. They will be assimilated by my employer.