cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Kulp (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CXF-1668) Wrong encoding using JMS Transport
Date Wed, 13 Aug 2008 14:54:44 GMT

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

Daniel Kulp commented on CXF-1668:
----------------------------------



Honestly, the BEST fix for this would be to update the StaxOutInterceptor (and In interceptor)
to allow for Readers/Writers in addition to streams.   In "text/string" mode, the JMS transport
could just use a StringReader/StringWriter and avoid the whole encoding issue.



> Wrong encoding using JMS Transport
> ----------------------------------
>
>                 Key: CXF-1668
>                 URL: https://issues.apache.org/jira/browse/CXF-1668
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.1
>         Environment: MS Windows XP, Sun Solaris
>            Reporter: Eduard Hildebrandt
>
> In class JMSConduit getBytes() is used to transform the string in a byte array.
>             byte[] bytes = null;
>             if (response instanceof String) {
>                 String requestString = (String)response;                
>                 bytes = requestString.getBytes();
>             } else {
>                 bytes = (byte[])response;
>             }
> getBytes() uses the standard encoding of the plattform. This is wrong because the encoding
of the message must be used.
> I have written an interceptor as workaround to solve this issue:
> public class EncodingInterceptor extends AbstractPhaseInterceptor<Message> {
>     public EncodingInterceptor() {
>         super(Phase.RECEIVE);
>     }
>     public void handleMessage(Message message) {   
>     	try {
>     	 	InputStream inputStream = message.getContent(InputStream.class);
>     	 	ByteArrayOutputStream baos = new ByteArrayOutputStream();    	
>         	while (true) {
>         		int datum = inputStream.read();
>         		if (datum == -1)
>         			break;
>         		baos.write(datum);
>         	}        
>         	String string = baos.toString();
>         	ByteArrayInputStream bais = new ByteArrayInputStream(string.getBytes("UTF-8"));
>         	message.setContent(InputStream.class, bais);
> 		} catch (IOException e) {
> 			e.printStackTrace();
> 		}
>     }
>     public void handleFault(Message messageParam) {
>     }
> }
> But the issue should be solved in JMSConduit class.

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


Mime
View raw message