Character sets in HTTP headers
Recently I was working with some web service products. We run the engine on WebSphere and OAS on Solaris, AIX and zOS so I was trying to get it embedded in each of our deployments. WebSphere on AIX was giving some curious responses to our SOAP requests. It was reporting that the SOAP request was empty. On the client, the request looked fine, but once it got to the SOAP servlet, there request was empty. On OAS, there were no errors and the same request came through properly.
I set up OC4J
to debug (since it's lightweight and easy to set up. I like it better than tomcat for j2ee dev and debugging.) It was throwing java.nio.charset.IllegalCharsetNameExceptions but the content-type header that was being sent was: Content-type: text/xml; charset="UTF-8"
Another architect found out what the problem was. It seems like the combination of WebSphere and IBM's JRE for AIX didn't like the quotes in the http header's charset. But the Sun JRE with WebSphere doesn't mind. Strange. So when we changed the header to: Content-type: text/xml; charset=UTF-8
, the request came through properly.
According to W3C's RFC2616 for HTTP 1.1
there are no quotes around the charset attribute. Even though there are quotes in other W3C examples (like Example 9 in theW3C SOAP Primer
So the moral of the story is that when you send SOAP requests over HTTP don't use quotes around the charset value of the around the Content-type header. Some app servers and JREs are flexible, but then again, some aren't.