You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Michael Allman (JIRA)" <ji...@apache.org> on 2009/10/15 17:08:31 UTC

[jira] Issue Comment Edited: (CXF-2475) When writing XML response, CXF uses request encoding instead of response encoding

    [ https://issues.apache.org/jira/browse/CXF-2475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12766082#action_12766082 ] 

Michael Allman edited comment on CXF-2475 at 10/15/09 8:07 AM:
---------------------------------------------------------------

I don't understand how this can be the correct behavior.

First, can you tell me what section in what spec states that the character set of the response should be the same as the character set of the request?  I searched WSI-BP and SOAP 1.2 and didn't find it.

Now here's why I think this can't be the correct behavior.  Suppose a Web service client sends an ISO-8859-1 encoded SOAP request to a Web service and the response document is encoded in UTF-8.  (For example, a client queries a Unicode database.)  If cxf sets the servlet response encoding to ISO-8859-1 and the response document includes characters outside ISO-8859-1, the response will be defective.

In my particular case, I have a subclass of CXFNonSpringServlet called DatabaseWebServiceServlet.  The first thing the invoke method of this class does is set the response encoding to UTF-8 so that I can successfully write a UTF-8 document.  I expect cxf to respect that setting.

Also, on the topic of standards, consider HTTP 1.1.  If the client expects the response to be encoded in a certain character set, it should specify it in the "Accept-Charset" request header (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2 ).  Otherwise, the server is free to choose whatever character encoding it wants for the response document.

Anyway, I don't see why the request document character set should be coupled to the response document character set.  The "Content-Type" is an entity header that tells the recipient the media type (including charset where applicable) of the entity body (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 ).  There's nothing in the HTTP 1.1 spec that says this header, when used in a request, specifies what the response media type or character set should be.

      was (Author: msa@allman.ms):
    I don't understand how this can be the correct behavior.

First, can you tell me what section in what spec states that the character set of the response should be the same as the character set of the request?  I searched WSI-BP and SOAP 1.2 and didn't find it.

Now here's why I think this can't be the correct behavior.  Suppose a Web service client sends an ISO-8859-1 encoded SOAP request to a Web service and the response document is encoded in UTF-8.  (For example, a client queries a Unicode database.)  If cxf sets the servlet response encoding to ISO-8859-1 and the response document includes characters outside ISO-8859-1, the response will be defective.

In my particular case, I have a subclass of CXFNonSpringServlet called DatabaseWebServiceServlet.  The first thing the invoke method of this class does is set the response encoding to UTF-8 so that I can successfully write a UTF-8 document.  I expect cxf to respect that setting.

Also, on the topic of standards, consider HTTP 1.1.  If the client expects the response to be encoded in a certain character set, it should specify it in the "Accept-Charset" request header (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2).  Otherwise, the server is free to choose whatever character encoding it wants for the response document.

Anyway, I don't see why the request document character set should be coupled to the response document character set.  The "Content-Type" is an entity header that tells the recipient the media type (including charset where applicable) of the entity body (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17).  There's nothing in the HTTP 1.1 spec that says this header, when used in a request, specifies what the response media type or character set should be.
  
> When writing XML response, CXF uses request encoding instead of response encoding
> ---------------------------------------------------------------------------------
>
>                 Key: CXF-2475
>                 URL: https://issues.apache.org/jira/browse/CXF-2475
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.2.4, 2.2.5
>            Reporter: Michael Allman
>            Priority: Minor
>         Attachments: AbstractHTTPDestination.patch
>
>
> When writing the SOAP XML response, CXF uses the ServletRequest encoding instead of the ServletResponse encoding.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.